How to Send Email Using SignalR

This post shows how SignalR could be used to send messages between different C# console clients using Message Pack as the protocol. An ASP.NET Core web application is used to host the SignalR Hub.

Setting up the Message Pack SignalR server

Add the Microsoft.AspNetCore.SignalR and the Microsoft.AspNetCore.SignalR.MsgPack NuGet packages to the ASP.NET Core server application where the SignalR Hub will be hosted. The Visual Studio NuGet Package Manager can be used for this.

Or just add it directly to the .csproj project file.

Setup a SignalR Hub as required. This is done by implementing the Hub class.

A DTO class is created to send the Message Pack messages. Notice that the class is a plain C# class with no Message Pack attributes, or properties.

Then add the Message Pack protocol to the SignalR service.

And configure the SignalR Hub in the Startup class Configure method of the ASP.NET Core server application.

Setting up the Message Pack SignalR client

Add the Microsoft.AspNetCore.SignalR.Client and the Microsoft.AspNetCore.SignalR.Client.MsgPackNuGet packages to the SignalR client console application.

The packages are added to the project file.

Create a Hub client connection using the Message Pack Protocol. The Url must match the URL configuration on the server.

The Hub can then be used to send or receive SignalR messages using the Message Pack as the binary serializer.

Testing

Start the server application, and 2 console applications. Then you can send and receive SignalR messages, which use Message Pack as the protocol.

(Visited 28 times, 1 visits today)

HostForLIFE.eu is Microsoft No #1 Recommended Windows and ASP.NET Hosting in European Continent. HostForLIFE.eu offers a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers. The company’s prices for shared and dedicated hosting are competitive; its features and perks are robust; and its stated commitment to outstanding customer service and support is manifest in its bevy of award-winning ancillary services.