mirror of
https://github.com/yawaflua/WebSockets.git
synced 2025-12-08 19:39:30 +02:00
Merge pull request #2 from yawaflua/develop
Change version of package and readme
This commit is contained in:
18
README.md
18
README.md
@@ -112,7 +112,23 @@ public class ChatController : WebSocketController
|
||||
}
|
||||
```
|
||||
|
||||
## Run any code on connection to
|
||||
## Run any code on connection to WebSocket
|
||||
```csharp
|
||||
services.AddSingleton(new WebSocketConfig()
|
||||
{
|
||||
OnOpenHandler = async (socket, context) =>
|
||||
{
|
||||
if (socket.WebSocketManager!.GetAllClients().Count(k =>
|
||||
Equals(k.ConnectionInfo!.RemoteIpAddress!.MapToIPv4(),
|
||||
socket.Client.ConnectionInfo!.RemoteIpAddress!.MapToIPv4())) >= 3)
|
||||
{
|
||||
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Too many users");
|
||||
}
|
||||
Console.WriteLine($"{socket.Client.Id} has been connected to {socket.Client.Path}");
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Lifecycle Management
|
||||
1. **Connection** - Automatically handled by middleware
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.0</Version>
|
||||
<Version>1.0.1</Version>
|
||||
<Title>yawaflua.WebSockets</Title>
|
||||
<Description>New AspNet controllers looks like websocket manager </Description>
|
||||
<Copyright>Dmitrii Shimanskii</Copyright>
|
||||
|
||||
Reference in New Issue
Block a user