Sphyrnidae Common Library
2.0.1
Shared Utilities/Library
|
SignalR is a messaging service which allows for things to be sent to/from clients/servers (or client-to-client or server-to-server). A message will be generated by either a client/server, and will be sent (using one of the Send() methods). This will then establish a connection to the SignalR server and send the message asynchronously. Awaiting the response of the Send() method does not actually await the completion of the event - but rather that a connection was established and the message should be sent.
The SignalR server will then process the request and will send a message to any subscribers of the message. If the subscriber is a server, the Receive() method will be executed. By default, all Send() methods will attempt to ensure that communication is established with the SignalR server. Automatic reconnect is enabled on the connection to help ensure that no messages are ever missed. The reconnect timeout logic is to attempt 20 times, each time waiting 1 second longer (eg. 1s, 2s, 3s, 4s, etc). Any failures will be logged.
Interface: ISignalR
Mock: SignalRMock
Implementation: SignalR
Static Wrapper: SignalRHub
// Setup Receive Method (Configure() method in Startup.cs) ISignalR signalR; // Should be injected IUser user; // Should be injected SignalRHub.Receive<User>(signalR, "http://signalR.mySite.com/user", "New User Added", user.NewUserAdded); // Send message (elsewhere in another application) ISignalR signalR; // Should be injected var user = new User(); SignalRHub.Send(signalR, "http://signalR.mySite.com/user", "NewUser", user);