Sanet.Transport.SignalR
0.4.1
dotnet add package Sanet.Transport.SignalR --version 0.4.1
NuGet\Install-Package Sanet.Transport.SignalR -Version 0.4.1
<PackageReference Include="Sanet.Transport.SignalR" Version="0.4.1" />
<PackageVersion Include="Sanet.Transport.SignalR" Version="0.4.1" />
<PackageReference Include="Sanet.Transport.SignalR" />
paket add Sanet.Transport.SignalR --version 0.4.1
#r "nuget: Sanet.Transport.SignalR, 0.4.1"
#:package Sanet.Transport.SignalR@0.4.1
#addin nuget:?package=Sanet.Transport.SignalR&version=0.4.1
#tool nuget:?package=Sanet.Transport.SignalR&version=0.4.1
Sanet.Transport.SignalR
ASP.NET Core SignalR implementation of the Sanet.Transport abstractions for real-time communication over networks.
Overview
Sanet.Transport.SignalR provides an implementation of the ITransportPublisher interface using ASP.NET Core SignalR, enabling real-time communication between applications over a network. The library encapsulates all SignalR infrastructure, keeping client applications clean from web server dependencies.
Features
- Real-time communication between applications over a network
- Client-server architecture with separate client and server publishers
- Automatic host discovery on simple local networks
- Self-contained SignalR infrastructure (no need to add ASP.NET Core to client apps)
Installation
dotnet add package Sanet.Transport.SignalR
Or via the Package Manager Console:
Install-Package Sanet.Transport.SignalR
Usage
Server-side (Host)
// Create a SignalR host (server)
var hostManager = await SignalRTransportFactory.CreateHostAsync(port: 5000);
// Get the server-side publisher
ITransportPublisher serverPublisher = hostManager.Publisher;
// Subscribe to messages from clients
serverPublisher.Subscribe(message => {
Console.WriteLine($"Server received: {message.CommandType}");
// Broadcast a response to all clients
serverPublisher.PublishMessage(new TransportMessage {
CommandType = "ServerResponse",
SourceId = Guid.NewGuid(),
Payload = "{\"server\": \"response\"}",
Timestamp = DateTime.UtcNow
});
});
Client-side
// Discover hosts on the network
var hosts = await discoveryService.DiscoverHostsAsync(timeoutSeconds: 5);
// Connect to the first discovered host
if (hosts.Count > 0)
{
// Create a client publisher connected to the host
ITransportPublisher clientPublisher = SignalRTransportFactory.CreateClient(hosts[0]);
// Subscribe to messages from the server
clientPublisher.Subscribe(message => {
Console.WriteLine($"Client received: {message.CommandType}");
});
// Send a message to the server
clientPublisher.PublishMessage(new TransportMessage {
CommandType = "ClientCommand",
SourceId = Guid.NewGuid(),
Payload = "{\"client\": \"data\"}",
Timestamp = DateTime.UtcNow
});
}
Manual Connection (Without Discovery)
// Connect to a known host
var hostInfo = new HostInfo { Url = "http://192.168.1.100:5000" };
ITransportPublisher clientPublisher = SignalRTransportFactory.CreateClient(hostInfo);
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net9.0
- Microsoft.AspNetCore.SignalR.Client (>= 9.0.3)
- Sanet.Transport (>= 1.0.1)
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 | |
|---|---|---|---|
| 0.4.1 | 308 | 4/7/2025 | |
| 0.4.0 | 345 | 4/1/2025 | |
| 0.3.2 | 322 | 3/31/2025 | |
| 0.3.1 | 288 | 3/30/2025 | |
| 0.3.0 | 307 | 3/29/2025 | |
| 0.2.0 | 254 | 3/29/2025 | |
| 0.2.0-preview | 278 | 3/28/2025 | |
| 0.1.0-preview | 280 | 3/28/2025 |