{"id":48842623,"url":"https://github.com/nnemirovsky/socket-storm","last_synced_at":"2026-04-15T03:03:08.507Z","repository":{"id":290978108,"uuid":"623565083","full_name":"nnemirovsky/socket-storm","owner":"nnemirovsky","description":"SocketStorm is a lightweight C# library that implements WebSocket server as a wrapper for the built-in HttpListener","archived":false,"fork":false,"pushed_at":"2025-05-01T16:52:58.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-01T17:50:33.843Z","etag":null,"topics":["csharp","csharp-library","dotnet","websocket","websocket-server","websockets"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nnemirovsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-04T16:14:19.000Z","updated_at":"2025-05-01T16:53:02.000Z","dependencies_parsed_at":"2025-05-01T18:01:58.884Z","dependency_job_id":null,"html_url":"https://github.com/nnemirovsky/socket-storm","commit_stats":null,"previous_names":["nnemirovsky/socket-storm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nnemirovsky/socket-storm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnemirovsky%2Fsocket-storm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnemirovsky%2Fsocket-storm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnemirovsky%2Fsocket-storm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnemirovsky%2Fsocket-storm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nnemirovsky","download_url":"https://codeload.github.com/nnemirovsky/socket-storm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnemirovsky%2Fsocket-storm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31824118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","csharp-library","dotnet","websocket","websocket-server","websockets"],"created_at":"2026-04-15T03:03:07.828Z","updated_at":"2026-04-15T03:03:08.500Z","avatar_url":"https://github.com/nnemirovsky.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SocketStorm\n\nSocketStorm is a lightweight C# library that implements WebSocket server as a wrapper for the built-in HttpListener.\n\n## Features\n\n- Simple API for creating WebSocket servers\n- Built on top of C# standard HttpListener\n- Lightweight with minimal dependencies\n- Easy integration with existing .NET applications\n\n## Quick Start\n\nCreating a WebSocket server with SocketStorm is simple. Here's how to get started:\n\n```csharp\nusing System.Text;\nusing SocketStorm.Server;\n\n// Create a WebSocket server instance\n// Parameters: host, port, path, data type, max connections, subprotocol\nusing WebSocketServer server = new(\n    \"*\",                   // Host: * for any available interface\n    24517,                 // Port: your chosen port number\n    \"/ws/stream\",          // Path: endpoint path for the WebSocket\n    WebSocketDataType.Text, // Data type: Text or Binary\n    50,                    // Max connections: limit of concurrent connections\n    \"my-protocol-v1\"       // Optional subprotocol\n);\n\n// Set up event handlers for WebSocket events\nserver.ConnectionOpened += (_, args) =\u003e {\n    Console.WriteLine($\"Connection opened. Session ID: {args.SessionId}\");\n};\n\nserver.ConnectionClosed += (_, args) =\u003e {\n    Console.WriteLine($\"Connection closed. Session ID: {args.SessionId}\");\n};\n\nserver.MessageReceived += (_, args) =\u003e {\n    // Convert received message bytes to string (for Text WebSockets)\n    var message = Encoding.UTF8.GetString(args.Data);\n    Console.WriteLine($\"Message received from {args.SessionId}: {message}\");\n    \n    // Echo the message back to the client\n    var response = Encoding.UTF8.GetBytes($\"Echo: {message}\");\n    server.SendAsync(response, args.SessionId).GetAwaiter().GetResult();\n};\n\nserver.ExceptionThrown += (_, args) =\u003e {\n    Console.WriteLine($\"Exception thrown: {args.Exception}\");\n};\n\n// Start the server\nawait server.StartAsync();\n\nConsole.WriteLine(\"WebSocket server started. Press Ctrl+C to stop.\");\n\n// Set up graceful shutdown\nCancellationTokenSource cts = new();\nConsole.CancelKeyPress += async (_, _) =\u003e {\n    await server.StopAsync();\n    server.Dispose();\n    cts.Cancel();\n};\n\n// Keep the application running\nwhile (!cts.IsCancellationRequested) {\n    await Task.Delay(100);\n}\n```\n\n### Client Connection Example (JavaScript)\n\nConnect to your WebSocket server from a web client:\n\n```javascript\n// Create a WebSocket connection\nconst socket = new WebSocket('ws://localhost:24517/ws/stream', 'my-protocol-v1');\n\n// Connection opened\nsocket.addEventListener('open', (event) =\u003e {\n    console.log('Connected to the server');\n    socket.send('Hello Server!');\n});\n\n// Listen for messages\nsocket.addEventListener('message', (event) =\u003e {\n    console.log('Message from server:', event.data);\n});\n\n// Connection closed\nsocket.addEventListener('close', (event) =\u003e {\n    console.log('Disconnected from the server');\n});\n\n// Error handling\nsocket.addEventListener('error', (event) =\u003e {\n    console.error('WebSocket error:', event);\n});\n```\n\n## Documentation\n\nDetailed documentation is coming soon.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnemirovsky%2Fsocket-storm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnnemirovsky%2Fsocket-storm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnemirovsky%2Fsocket-storm/lists"}