Change version of package and readme

This commit is contained in:
Dmitri Shimanski
2025-03-30 00:47:54 +03:00
parent b979b9bc22
commit dc762db048
2 changed files with 18 additions and 2 deletions

View File

@@ -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

View File

@@ -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>