SignalRems.Server 1.0.15

dotnet add package SignalRems.Server --version 1.0.15
NuGet\Install-Package SignalRems.Server -Version 1.0.15
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="SignalRems.Server" Version="1.0.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SignalRems.Server --version 1.0.15
#r "nuget: SignalRems.Server, 1.0.15"
#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 SignalRems.Server as a Cake Addin
#addin nuget:?package=SignalRems.Server&version=1.0.15

// Install SignalRems.Server as a Cake Tool
#tool nuget:?package=SignalRems.Server&version=1.0.15

SignalR EMS

Description

SignalRems is one Enterprise Messaging System (EMS) implemented by .NET Standard SignalR. It provides two communication models, RPC and PUB/SUB. This library will provide strong typed API to help client application communicate with server. It is using Newtonsoft.json or MessagePack for serialization/deserialization. In PUB/SUB mode, it subscribes with filter of Lambda expression.

Dependency

This libiary is built on SingalR, hence the server application must be using "Microsoft.NET.Sdk.Web" SDK. The client side could use any .net 6.0 SDK.

API usage

RPC Server

  1. Configure WebApplication builder;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalRemsService(); // Using Json serialization/deserialization
// builder.Services.AddSignalRemsService(true); // MessagePack serialization/deserialization
  1. Setup endpoint for app instance:
var app = builder.Build();
app.MapSignalRemsRpcHub("/signalr/ems/example/rpc");
  1. Register RPC handler in IRpcService instance. IRpcService instance is singleton and can be get from dependency injection, handler implements IRpcHandler<,> interface to handle the RPC logic;
IRpcService rpcService;
IRpcHandler<GetUserNameRequest, GetUserNameResponse> handler;
rpcService.RegisterHandler<GetUserNameRequest, GetUserNameResponse>(handler);

RPC Client

  1. Config RPC client into dependency injection;
services.AddSignalRemsClient(); // Using Json serialization/deserialization
// services.AddSignalRemsClient(true); // MessagePack serialization/deserialization
  1. Make connection and call:
await _rpcClient.ConnectAsync("https://localhost:7198", "/signalr/ems/example/rpc", stoppingToken);
var request = new GetUserNameRequest() { UserId = i.ToString() };
var response = await _rpcClient.SendAsync<GetUserNameRequest, GetUserNameResponse>(request);

PUB/SUB Server

  1. Configure WebApplication builder;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalRemsService();
  1. Setup endpoint for app instance:
var app = builder.Build();
app.MapSignalRemsPublisherHub("/signalr/ems/example/pubsub");
  1. Create publisher from IPublisherService, IPublisherService is singleton instance;
IPublisherService publisherService;
var publisher =  _publisherService.CreatePublisher<Person, int>("Message");
  1. Publish item to topic
publisher.Publish(new Person() { Id = id, Age = random.Next(95), Name = $"Person_{id:000}" });

PUB/SUB Client

  1. Config subscriber client into dependency injection;
services.AddSignalRemsClient();
  1. Make connection and call. It supports Lambda expression as filter. This Lambda expression must be able to be explained from both server and client.
ISubscriptionHandler<Person> handler;
await _subscriberClient.ConnectAsync("https://localhost:7198", "/signalr/ems/example/pubsub", stoppingToken);
var subscription = await _subscriberClient.SubscribeAsync("Message", handler, p=> p.Age > 60);

Please note, one client can only be used to do one subscription. The dispose method will stop the subscription and disconnect from server. We can get multiple client instances from DI container to subscribe with differnet topic/filter.

License

This project is open source and follows MIT license.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 was computed.  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

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
1.0.15 156 8/8/2023
1.0.14 372 10/10/2022
1.0.13 349 9/29/2022
1.0.12 366 8/25/2022
1.0.11 364 8/22/2022
1.0.10 368 7/25/2022
1.0.9 353 7/23/2022
1.0.8 384 7/12/2022
1.0.7 379 7/12/2022
1.0.6 400 7/3/2022
1.0.5 375 6/24/2022
1.0.4 365 6/24/2022
1.0.3 378 6/23/2022
1.0.2 358 6/13/2022
1.0.1 378 6/10/2022
1.0.0 380 6/7/2022
0.2.2-preview 137 4/5/2022
0.2.1-preview 150 4/3/2022
0.2.0-preview 156 4/3/2022
0.1.2-preview 161 4/2/2022
0.1.1-preview 165 4/1/2022
0.1.0-preview 164 3/31/2022