Multicaster 0.1.12

dotnet add package Multicaster --version 0.1.12                
NuGet\Install-Package Multicaster -Version 0.1.12                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Multicaster" Version="0.1.12" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Multicaster --version 0.1.12                
#r "nuget: Multicaster, 0.1.12"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Multicaster as a Cake Addin
#addin nuget:?package=Multicaster&version=0.1.12

// Install Multicaster as a Cake Tool
#tool nuget:?package=Multicaster&version=0.1.12                

Multicaster

This framework provides a proxy for transparently invoking methods of multiple POCO instances or remote clients through an interface.

For instance, a single call to IGreeter.Hello can invoke methods on several objects or broadcast the call to remote clients like those using MagicOnion or SignalR.

The framework incorporates the concept of groups that bundle together the receivers (targets) to enable transparent invocation, allowing receivers to be added or removed flexibly from the group for ease of management.

Usage

In-Memory (Plain Old CLR Object)

public interface IGreeterReceiver
{
    void OnMessage(string sender, string message);
}

public class GreeterReceiver(string name) : IGreeterReceiver
{
    public void OnMessage(string sender, string message)
        => Console.WriteLine($"[{name}] <{sender}> {message}")
}
// Create receivers.
var receiverA = new GreeterReceiver("A");
var receiverIdA = Guid.NewGuid();
var receiverB = new GreeterReceiver("B");
var receiverIdB = Guid.NewGuid();
var receiverC = new GreeterReceiver("C");
var receiverIdC = Guid.NewGuid();

// Create a in-memory group provider.
var groupProvider = new InMemoryGroupProvider(DynamicInMemoryProxyFactory.Instance);

// Create a group and add receivers to the group.
var group = groupProvider.GetOrAddSynchronousGroup<Guid, IGreeterReceiver>("MyGroup");
group.Add(receiverIdA, receiverA);
group.Add(receiverIdB, receiverB);
group.Add(receiverIdC, receiverC);

// Call receivers via proxy.
group.All.OnMessage("System", "Hello");
group.Except([receiverIdA]).OnMessage("System", "Hello without A");

// Call the receiver directly. (Normal method call)
receiverA.OnMessage("DirectMessage", "Sent a message to the receiver directly.");
Outputs
[A] <System> Hello
[B] <System> Hello
[C] <System> Hello
[B] <System> Hello without A
[C] <System> Hello without A
[A] <DirectMessage> Sent a message to the receiver directly.

API

IMulticastGroupProvider interface

  • IMulticastAsyncGroup<TKey, TReceiver> GetOrAddGroup<TKey, TReceiver>(string name);
  • IMulticastSyncGroup<TKey, TReceiver> GetOrAddSynchronousGroup<TKey, TReceiver>(string name);

IMulticastGroup<TKey, T> interface

  • TReceiver All { get; }
  • TReceiver Except(ImmutableArray<TKey> excludes);
  • TReceiver Only(ImmutableArray<TKey> targets);
  • TReceiver Single(TKey target);
  • void Dispose()
    • Dispose and unregister the group from a group provider.

IMulticastAsyncGroup<TKey, T> interface (implements IMulticastGroup<TKey, T>)

  • ValueTask AddAsync(TKey key, TReceiver receiver, CancellationToken cancellationToken = default);
  • ValueTask RemoveAsync(TKey key, CancellationToken cancellationToken = default);
  • ValueTask<int> CountAsync(CancellationToken cancellationToken = default);

IMulticastSyncGroup<TKey, T> interface (implements IMulticastGroup<TKey, T>)

  • void Add(TKey key, TReceiver receiver);
  • void Remove(TKey key);
  • int Count();

Transports and supported features

Transport Multicast Synchronous Count/CountAsync Client Results
InMemory ✔️ ✔️ ✔️ ✔️
Remote (InMemory) ✔️ ✔️ ✔️ ✔️
Redis ✔️ ✔️ - -
NATS ✔️ ✔️ - -
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Multicaster:

Package Downloads
MagicOnion.Server

MagicOnion server built on top of ASP.NET Core. Unified Realtime/API framework for .NET platform and Unity.

Multicaster.Distributed.Redis

Package Description

Multicaster.Distributed.Nats

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Multicaster:

Repository Stars
Cysharp/MagicOnion
Unified Realtime/API framework for .NET platform and Unity.
Version Downloads Last updated
0.1.12 12,485 7/11/2024
0.1.11 2,838 6/17/2024
0.1.10 135 6/12/2024
0.1.9 183 6/7/2024
0.1.8 142 6/7/2024
0.1.7 121 6/3/2024
0.1.6 140 6/3/2024
0.1.5 151 5/30/2024
0.1.4 142 5/30/2024
0.1.3 152 5/30/2024
0.1.2 139 5/29/2024
0.1.1 161 5/29/2024
0.1.0 136 5/28/2024