DevCodeSpace.NetSocketHandler 1.0.0

dotnet add package DevCodeSpace.NetSocketHandler --version 1.0.0
                    
NuGet\Install-Package DevCodeSpace.NetSocketHandler -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DevCodeSpace.NetSocketHandler" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevCodeSpace.NetSocketHandler" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DevCodeSpace.NetSocketHandler" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevCodeSpace.NetSocketHandler --version 1.0.0
                    
#r "nuget: DevCodeSpace.NetSocketHandler, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DevCodeSpace.NetSocketHandler@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevCodeSpace.NetSocketHandler&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DevCodeSpace.NetSocketHandler&version=1.0.0
                    
Install as a Cake Tool

NetSocketHandler

A powerful, flexible .NET WebSocket manager for seamless connection handling, intelligent routing, and real-time broadcasting

Plugin Banners

๐Ÿ“ฆ Quick Installation

NuGet CLI:

dotnet add package NetSocketHandler

Package Manager Console:

Install-Package NetSocketHandler

โœจ Key Features

๐Ÿ”— Smart Connection Management - Effortlessly add, remove, and organize WebSocket connections with unique identifiers
๐ŸŽฏ Precision Messaging - Send targeted messages to specific clients or broadcast to all active connections
๐Ÿท๏ธ Flexible Identification - Assign custom identifiers for organized, scalable client communication
โšก High Performance - Optimized for real-time applications with minimal overhead
๐Ÿงช Testable Architecture - Built with dependency injection support for clean, maintainable code

๐Ÿ› ๏ธ Usage Examples

1. Connection Management Made Simple

The ConnectionManager<TData> provides intuitive WebSocket connection management:

using NetSocketHandler.Interface;
using NetSocketHandler.Implementation;
using System.Net.WebSockets;
 
// Initialize the connection manager
var connectionManager = new ConnectionManager<string>();
 
// Add a new WebSocket connection
connectionManager.AddConnection("user_123", webSocket, "john_doe");
 
// Send targeted message to specific user
await connectionManager.SendDataToIdentifier("john_doe", "Welcome back, John!");
 
// Broadcast announcement to all connected clients
await connectionManager.SendDataAsync("๐ŸŽ‰ New feature released!");

2. Streamlined Connection Handling

Use ConnectionHandler<TData> for seamless WebSocket connection processing:

using NetSocketHandler;
 
// Create connection handler
var connectionHandler = new ConnectionHandler<string>();
 
// Handle incoming WebSocket connection
await connectionHandler.HandleConnectionAsync(webSocket, "session_456");

3. Dependency Injection Ready

Built for modern .NET applications with clean architecture:

public class ChatService
{
    private readonly IConnectionManager<string> _connectionManager;
 
    public ChatService(IConnectionManager<string> connectionManager)
    {
        _connectionManager = connectionManager;
    }
 
    public async Task SendChatMessage(string message, string roomId)
    {
        // Send to specific room
        await _connectionManager.SendDataToIdentifier(roomId, message);
    }
 
    public async Task BroadcastSystemMessage(string message)
    {
        // Notify all connected users
        await _connectionManager.SendDataAsync($"๐Ÿ“ข System: {message}");
    }
}

๐Ÿ—๏ธ Architecture Overview

Core Interfaces:

๐Ÿ”ง IConnectionManager<TData> - Contract for connection management operations
โšก Support for generic data types for flexible message handling
๐Ÿ›ก๏ธ Thread-safe operations for concurrent WebSocket connections

Key Operations:

โž• Add/Remove connections dynamically
๐Ÿ” Retrieve connections by ID or custom identifier
๐Ÿ“ค Send messages to individual or multiple connections
๐Ÿ“ก Broadcast capabilities for real-time updates

๐ŸŽฏ Perfect For

๐Ÿ’ฌ Real-time Chat Applications
๐Ÿ”” Live Notifications Systems
๐Ÿค Collaborative Tools
๐ŸŽฎ Gaming Servers
๐Ÿ  IoT Device Communication
๐Ÿ“ˆ Trading Platforms

Code Contributors

Plugin Banners

โญ Star this repository if NetSocketHandler helped your project!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 287 6/9/2025