Cocoar.SignalARRR.Server 4.0.0-beta.6

This is a prerelease version of Cocoar.SignalARRR.Server.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Cocoar.SignalARRR.Server --version 4.0.0-beta.6
                    
NuGet\Install-Package Cocoar.SignalARRR.Server -Version 4.0.0-beta.6
                    
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="Cocoar.SignalARRR.Server" Version="4.0.0-beta.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cocoar.SignalARRR.Server" Version="4.0.0-beta.6" />
                    
Directory.Packages.props
<PackageReference Include="Cocoar.SignalARRR.Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cocoar.SignalARRR.Server --version 4.0.0-beta.6
                    
#r "nuget: Cocoar.SignalARRR.Server, 4.0.0-beta.6"
                    
#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.
#:package Cocoar.SignalARRR.Server@4.0.0-beta.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cocoar.SignalARRR.Server&version=4.0.0-beta.6&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Cocoar.SignalARRR.Server&version=4.0.0-beta.6&prerelease
                    
Install as a Cake Tool

SignalARRR

Typed bidirectional RPC over ASP.NET Core SignalR.

Both server and client can call each other's methods through shared interfaces, with compile-time proxy generation, streaming, cancellation propagation, and ASP.NET Core authorization.

Features

  • Typed bidirectional RPC — server calls client methods, client calls server methods, both through shared interfaces
  • Compile-time proxy generation — Roslyn source generator produces proxies from [SignalARRRContract] interfaces (zero reflection)
  • Organized hub methods — split hub logic across multiple ServerMethods<T> classes with full DI support
  • StreamingIAsyncEnumerable<T>, IObservable<T>, and ChannelReader<T> in both directions
  • CancellationToken propagation — server can cancel client operations remotely
  • Authorization — method-level, class-level, and hub-level [Authorize] with automatic inheritance
  • Server-to-client calls from anywhere — inject ClientManager in controllers, background services, etc.
  • Optional runtime proxy fallbackDispatchProxy-based package for plugin/dynamic scenarios

Packages

Package Purpose
Cocoar.SignalARRR.Contracts [SignalARRRContract] attribute + source generator — reference from shared interface projects
Cocoar.SignalARRR.Server Server-side: HARRR hub, ServerMethods, authorization, ClientManager
Cocoar.SignalARRR.Client Client-side: HARRRConnection, typed proxies, event handlers
Cocoar.SignalARRR.DynamicProxy Opt-in runtime proxy fallback via DispatchProxy

Quick Start

1. Define shared interfaces

In your shared project, reference Cocoar.SignalARRR.Contracts:

[SignalARRRContract]
public interface IChatHub {
    Task SendMessage(string user, string message);
    Task<List<string>> GetHistory();
    IAsyncEnumerable<string> StreamMessages(CancellationToken ct);
}

[SignalARRRContract]
public interface IChatClient {
    void ReceiveMessage(string user, string message);
    Task<string> GetClientName();
}

2. Server setup

// Program.cs
builder.Services.AddSignalR();
builder.Services.AddSignalARRR(options => options
    .AddServerMethodsFrom(typeof(Program).Assembly));

app.UseRouting();
app.MapHARRRController<ChatHub>("/chathub");
// Hub (can be empty — methods go in ServerMethods classes)
public class ChatHub : HARRR {
    public ChatHub(IServiceProvider sp) : base(sp) { }
}

// Server methods (auto-discovered, DI works)
public class ChatMethods : ServerMethods<ChatHub>, IChatHub {
    public Task SendMessage(string user, string message) { ... }
    public Task<List<string>> GetHistory() { ... }
    public async IAsyncEnumerable<string> StreamMessages(
        [EnumeratorCancellation] CancellationToken ct) {
        while (!ct.IsCancellationRequested) {
            yield return $"msg-{DateTime.Now:ss}";
            await Task.Delay(1000, ct);
        }
    }
}

3. Client setup

var connection = HARRRConnection.Create(builder => {
    builder.WithUrl("https://localhost:5001/chathub");
});
await connection.StartAsync();

// Typed calls
var chat = connection.GetTypedMethods<IChatHub>();
await chat.SendMessage("Alice", "Hello!");
var history = await chat.GetHistory();

// Streaming
await foreach (var msg in chat.StreamMessages(cancellationToken)) {
    Console.WriteLine(msg);
}

4. Server-to-client calls

// Inside ServerMethods — use ClientContext
var client = ClientContext.GetTypedMethods<IChatClient>();
var name = await client.GetClientName();

// Outside hub context — inject ClientManager
public class NotificationService {
    private readonly ClientManager _clients;
    public NotificationService(ClientManager clients) => _clients = clients;

    public void Notify(string connectionId) {
        var client = _clients.GetTypedMethods<IChatClient>(connectionId);
        client.ReceiveMessage("System", "Hello from server!");
    }
}

Framework Support

  • Server: .NET 10
  • Client: .NET 10

Building from Source

dotnet build src/Cocoar.SignalARRR.slnx
dotnet test src/Cocoar.SignalARRR.slnx

License

MIT License — see LICENSE for details.

Contributing

See CONTRIBUTING.md for guidelines.


Maintainer: Bernhard Windisch

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0-beta.8 39 3/3/2026
4.0.0-beta.6 35 3/3/2026
4.0.0-beta.2 38 3/3/2026
0.1.0-beta.85 46 2/28/2026