A comprehensive WebSocket library for .NET providing both client and server implementations with support for multiple application types.
✅Full-duplex communication - Real-time bidirectional messaging ✅Automatic reconnection - Configurable retry policies ✅User management - Track and manage connected users ✅State management - Comprehensive state tracking for client/server ✅Cross-platform - Works with ASP.NET Core, Blazor, Console apps ✅Thread-safe - Safe for concurrent operations ✅Memory efficient - UsesArrayPool for buffer management ✅Event-driven - Comprehensive event system ✅Dependency Injection - Seamless integration with ASP.NET Core A high-performance WebSocket library for .NET including:
MaanfeeWebSocketServer - Full-featured WebSocket server with user managementMaanfeeWebSocketClient - WebSocket client with auto-reconnection capabilityMaanfeeWebSocketOption - Advanced configuration for connection settingsMaanfeeWebSocketUser - Management of connected user informationWebSocketServerState &WebSocketClientState - Comprehensive state managementEvent arguments and helper classes Example implementations demonstrating usage in different application types.
Method Description Start()Start the server StopAsync()Gracefully stop the server HandleWebSocketConnectionAsync(WebSocket)Handle new WebSocket connections SendToAllAsync(string)Send message to all connected clients SendToClientAsync(string , string)Send message to specific client GetConnectedUsersCount()Get count of connected users GetConnectedUserIds()Get list of connected user IDs GetUserById(string)Get user by ID GetAllUsers()Get all users Dispose()Clean up resources
Events Description ClientConnectedWhen new client connects ClientDisconnectedWhen client disconnects ServerStoppedWhen server stops MessageReceivedWhen message received from client StateChangedWhen server state changes
Method Description ConnectAsync()Connect to WebSocket server SendMessageAsync(string)Send message to server DisconnectAsync()Disconnect from server Dispose()Clean up resources
Events Description MessageReceivedWhen message received from server ConnectionClosedWhen connection closes ErrorOccurredWhen error occurs ConnectedWhen connection established successfully StateChangedWhen client state changes
Package Manager
<PackageReference Include =" Maanfee.WebSocket" Version =" *" /> Solution Configuration Guide Steps to Configure Multiple Startup Projects Open the Solution
Right-click on the solution name in the Solution Explorer Access Solution Properties
Configure Startup Projects
Navigate toMultiple startup projects Available Project Profiles Server : Web API ServerClients :Server : Console ServerClients :Blazor Server Profile (Recommended) Server : Blazor ServerClients :Each profile allows you to set different combinations of server and client applications for testing and development purposes.