Skip to content

Commit a2fce73

Browse files
Provide Microsoft.AspNetCore.SignalR.Client package README (#57718)
1 parent 46ad888 commit a2fce73

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## About
2+
3+
`Microsoft.AspNetCore.SignalR.Client` provides the .NET client for ASP.NET Core SignalR, which simplifies adding real-time web functionality to apps.
4+
5+
## Key Features
6+
7+
SignalR provides the following capabilities:
8+
* Automatic connection management
9+
* Sending messages to all connected clients simultaneously
10+
* Sending messages to specific clients or groups of clients
11+
* Scaling to handle increasing traffic
12+
13+
## How to Use
14+
15+
To use `Microsoft.AspNetCore.SignalR.Client`, follow these steps:
16+
17+
### Installation
18+
19+
```shell
20+
dotnet add package Microsoft.AspNetCore.SignalR.Client
21+
```
22+
23+
### Configuration
24+
25+
See the [ASP.NET Core SignalR docs](https://learn.microsoft.com/aspnet/core/signalr/hubs) for information about how to configure SignalR hubs on the server.
26+
27+
Then, you can configure the client to connect to the hub. For example:
28+
29+
```csharp
30+
var connection = new HubConnectionBuilder()
31+
.WithUrl("http://localhost:53353/Chat")
32+
.Build();
33+
34+
connection.On("ReceiveMessage", (string user, string message) =>
35+
{
36+
Console.WriteLine($"{user}: {message}");
37+
});
38+
39+
await connection.StartAsync();
40+
```
41+
42+
## Main Types
43+
44+
The main types provided by `Microsoft.AspNetCore.SignalR.Client` include:
45+
* `HubConnectionBuilder`: Provides an abstraction to construct new SignalR hub connections
46+
* `HubConnection`: Defines methods for managing a hub connection, including:
47+
* Starting and stopping the connection
48+
* Sending and receiving messages
49+
* Handling disconnects and attempting reconnects
50+
* `HubConnectionOptions`: Provides options for configuring a `HubConnection`
51+
52+
## Additional Documentation
53+
54+
For additional documentation and examples, refer to the [official documentation](https://learn.microsoft.com/aspnet/core/signalr/dotnet-client) on the .NET client for ASP.NET Core SignalR.
55+
56+
## Feedback & Contributing
57+
58+
`Microsoft.AspNetCore.SignalR.Client` is released as open-source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/aspnetcore).

0 commit comments

Comments
 (0)