Client for ASP.NET Core SignalR This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.AspNetCore.SignalR.ClientMicrosoft.AspNetCore.SignalR.Client provides the .NET client for ASP.NET Core SignalR, which simplifies adding real-time web functionality to apps.
SignalR provides the following capabilities:
To use Microsoft.AspNetCore.SignalR.Client, follow these steps:
dotnet add package Microsoft.AspNetCore.SignalR.Client
See the ASP.NET Core SignalR docs for information about how to configure SignalR hubs on the server.
Then, you can configure the client to connect to the hub. For example:
var connection = new HubConnectionBuilder()
.WithUrl("http://localhost:53353/Chat")
.Build();
connection.On("ReceiveMessage", (string user, string message) =>
{
Console.WriteLine($"{user}: {message}");
});
await connection.StartAsync();
The main types provided by Microsoft.AspNetCore.SignalR.Client include:
HubConnectionBuilder: Provides an abstraction to construct new SignalR hub connectionsHubConnection: Defines methods for managing a hub connection, including:
HubConnectionOptions: Provides options for configuring a HubConnectionFor additional documentation and examples, refer to the official documentation on the .NET client for ASP.NET Core SignalR.
Microsoft.AspNetCore.SignalR.Client is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.