{"id":24236934,"url":"https://github.com/byronap/websockets","last_synced_at":"2026-05-10T17:51:30.352Z","repository":{"id":141942441,"uuid":"383293834","full_name":"ByronAP/websockets","owner":"ByronAP","description":".NET library that simplifies the usage of client websockets","archived":false,"fork":false,"pushed_at":"2023-05-16T23:53:20.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-02-14T23:04:51.512Z","etag":null,"topics":["dotnet","dotnet-core","netstandard","websocket","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/ByronAP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":["ByronAP"]}},"created_at":"2021-07-06T00:19:22.000Z","updated_at":"2022-12-14T03:16:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"905dffe5-f36f-45f8-a4ca-f0eccff8c0ee","html_url":"https://github.com/ByronAP/websockets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByronAP%2Fwebsockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByronAP%2Fwebsockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByronAP%2Fwebsockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByronAP%2Fwebsockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ByronAP","download_url":"https://codeload.github.com/ByronAP/websockets/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241868464,"owners_count":20033822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dotnet","dotnet-core","netstandard","websocket","websockets"],"created_at":"2025-01-14T19:50:16.160Z","updated_at":"2026-05-10T17:51:30.304Z","avatar_url":"https://github.com/ByronAP.png","language":"C#","funding_links":["https://github.com/sponsors/ByronAP"],"categories":[],"sub_categories":[],"readme":"# ByronAP.Net.WebSockets\n\nByronAP.Net.WebSockets is a .NET library that simplifies the usage of client websockets.\n\n[![Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/ByronAP)\n[![NuGet version (SoftCircuits.Silk)](https://img.shields.io/nuget/v/ByronAP.Net.WebSockets.svg?style=flat-square)](https://www.nuget.org/packages/ByronAP.Net.WebSockets/)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FByronAP%2Fwebsockets.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FByronAP%2Fwebsockets?ref=badge_shield)\n\n## Usage\n\n```c#\nusing System;\nusing System.Threading.Tasks;\n\nnamespace WebSocketUsageDemo\n{\n    class Program\n    {\n        const string WebSocketHost = \"wss://echo.websocket.org\";\n        const string TestMessage = \"Hi, this is a websocket text message.\";\n\n        static async Task Main()\n        {\n            // Create an instance of the WebSocketOptions class\n            var options = new ByronAP.Net.WebSockets.WebSocketOptions(WebSocketHost);\n            // setup options as needed\n\n            // create a client instance and make sure it is automatically disposed of by a using statement\n            using var client = new ByronAP.Net.WebSockets.WebSocketClient(options);\n\n            // hookup to the events we want to receive\n            client.ConnectionStateChanged += Client_ConnectionStateChanged;\n            client.MessageReceived += Client_MessageReceived;\n            client.DataReceived += Client_DataReceived;\n\n            // start the connection and ensure it connected sucessfully\n            var connResult = await client.ConnectAsync();\n            if(!connResult.Item1)\n            {\n                // connection failed\n                Console.WriteLine($\"{DateTime.Now} ERROR: {connResult.Item2}\");\n                await Task.Delay(2000);\n                return;\n            }\n\n            // send our test message\n            Console.WriteLine($\"{DateTime.Now} Message Sent: {TestMessage}\");\n            await client.SendTextAsync(TestMessage);\n\n            // wait a bit before exiting the app\n            await Task.Delay(2000);\n        }\n\n        /// \u003csummary\u003e\n        /// This gets called when the state of the connection changes\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"sender\"\u003e\u003c/param\u003e\n        /// \u003cparam name=\"newWebSocketState\"\u003e\u003c/param\u003e\n        /// \u003cparam name=\"oldWebSocketState\"\u003e\u003c/param\u003e\n        private static void Client_ConnectionStateChanged(object sender, System.Net.WebSockets.WebSocketState newWebSocketState, System.Net.WebSockets.WebSocketState oldWebSocketState)\n        {\n            Console.WriteLine($\"{DateTime.Now} State Changed: from {oldWebSocketState} to {newWebSocketState}\");\n        }\n\n        /// \u003csummary\u003e\n        /// This gets called when a text message is received\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"sender\"\u003e\u003c/param\u003e\n        /// \u003cparam name=\"message\"\u003e\u003c/param\u003e\n        private static void Client_MessageReceived(object sender, string message)\n        {\n            Console.WriteLine($\"{DateTime.Now} Message Received: {message}\");\n        }\n\n        /// \u003csummary\u003e\n        /// This gets called when binary data is received\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"sender\"\u003e\u003c/param\u003e\n        /// \u003cparam name=\"data\"\u003e\u003c/param\u003e\n        private static void Client_DataReceived(object sender, byte[] data)\n        {\n            Console.WriteLine($\"{DateTime.Now} Data Received: {data.Length} bytes\");\n        }\n    }\n}\n```\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyronap%2Fwebsockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyronap%2Fwebsockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyronap%2Fwebsockets/lists"}