![]() |
VOOZH | about |
dotnet add package Multicaster --version 2.1.1
NuGet\Install-Package Multicaster -Version 2.1.1
<PackageReference Include="Multicaster" Version="2.1.1" />
<PackageVersion Include="Multicaster" Version="2.1.1" />Directory.Packages.props
<PackageReference Include="Multicaster" />Project file
paket add Multicaster --version 2.1.1
#r "nuget: Multicaster, 2.1.1"
#:package Multicaster@2.1.1
#addin nuget:?package=Multicaster&version=2.1.1Install as a Cake Addin
#tool nuget:?package=Multicaster&version=2.1.1Install as a Cake Tool
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.
A Group is requested from IMulticastGroupProvider by specifying a name, key type, and calling interface. If the Group does not exist, it will be created when it is requested.
There are synchronous and asynchronous operation versions of the Group, which can be selected according to the use case and supported functions.
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}")
}
var group = groupProvider.GetOrAddSynchronousGroup<Guid, IGreeterReceiver>("MyGroup");
You can register a receiver instance that implements the interface for the call with the key to the retrieved Group.
var receiverId = Guid.NewGuid();
group.Add(receiverId, receiver);
In the case of MagicOnion, you can register the Client property that can be used in StreamingHub.
You get a proxy object that calls the receiver via the Group's properties and methods such as All, Except, Only, and Single, and you can call the methods.
group.All.OnMessage("A", "Hello");
Groups can be deleted from memory by calling Dispose.
group.Dispose();
Note that this means that in-memory groups are completely deleted, but if Redis/NATS is used as the backplane, they are only deleted from memory on the .NET server that called it, and not from other servers.
Multicaster allows you to call the methods of multiple instances at once.
For example, it is possible to call multiple instances that implement IGreeterReceiver.OnMessage at once. The code below is an example of this.
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.
using 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.");
[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.
IMulticastGroupProvider interfaceIMulticastAsyncGroup<TKey, TReceiver> GetOrAddGroup<TKey, TReceiver>(string name);IMulticastSyncGroup<TKey, TReceiver> GetOrAddSynchronousGroup<TKey, TReceiver>(string name);IMulticastGroup<TKey, T> interfaceTReceiver All { get; }TReceiver Except(IEnumerable<TKey> excludes);TReceiver Only(IEnumerable<TKey> targets);TReceiver Single(TKey target);void Dispose()
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();| Transport | Multicast | Synchronous | Count/CountAsync | Client Results |
|---|---|---|---|---|
| InMemory | ✔️ | ✔️ | ✔️ | ✔️ |
| Remote (InMemory) | ✔️ | ✔️ | ✔️ | ✔️ |
| Redis | ✔️ | ✔️ | - | - |
| NATS | ✔️ | ✔️ | - | - |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on Multicaster:
| Package | Downloads |
|---|---|
|
MagicOnion
Unified Realtime/API framework for .NET platform and Unity. This package is meta package that includes MagicOnion.Server and MagicOnion.Client. |
|
|
MagicOnion.Server
MagicOnion server built on top of ASP.NET Core. Unified Realtime/API framework for .NET platform and Unity. |
|
|
MagicOnion.Server.Redis
Redis backplane for MagicOnion. |
|
|
MagicOnion.Server.JsonTranscoding
Provides JSON transcoding support to the MagicOnion server. |
|
|
MagicOnion.Server.JsonTranscoding.Swagger
Provides Swagger support for MagicOnion JSON transcoding on the server. |
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 |
|---|---|---|
| 2.1.1 | 189,784 | 7/29/2025 |
| 2.1.0 | 192 | 7/29/2025 |
| 2.0.1 | 108,188 | 5/1/2025 |
| 2.0.0 | 46,799 | 4/14/2025 |
| 2.0.0-preview.1 | 168 | 4/11/2025 |
| 1.0.0 | 79,210 | 1/10/2025 |
| 0.1.12 | 14,629 | 7/11/2024 |
| 0.1.11 | 4,267 | 6/17/2024 |
| 0.1.10 | 271 | 6/12/2024 |
| 0.1.9 | 316 | 6/7/2024 |
| 0.1.8 | 260 | 6/7/2024 |
| 0.1.7 | 243 | 6/3/2024 |
| 0.1.6 | 257 | 6/3/2024 |
| 0.1.5 | 326 | 5/30/2024 |
| 0.1.4 | 303 | 5/30/2024 |
| 0.1.3 | 289 | 5/30/2024 |
| 0.1.2 | 261 | 5/29/2024 |
| 0.1.1 | 267 | 5/29/2024 |