{"id":20663470,"url":"https://github.com/shaunabanana/unity-websocket-server","last_synced_at":"2025-04-19T15:55:27.173Z","repository":{"id":40597662,"uuid":"376593726","full_name":"shaunabanana/unity-websocket-server","owner":"shaunabanana","description":"A simple, zero-dependency WebSocket server for Unity.","archived":false,"fork":false,"pushed_at":"2022-06-28T04:57:49.000Z","size":96,"stargazers_count":57,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-22T10:12:43.406Z","etag":null,"topics":["unity","websocket","websocket-server"],"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/shaunabanana.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}},"created_at":"2021-06-13T16:45:54.000Z","updated_at":"2024-04-22T08:41:30.000Z","dependencies_parsed_at":"2022-09-20T12:14:07.973Z","dependency_job_id":null,"html_url":"https://github.com/shaunabanana/unity-websocket-server","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/shaunabanana%2Funity-websocket-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaunabanana%2Funity-websocket-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaunabanana%2Funity-websocket-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaunabanana%2Funity-websocket-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaunabanana","download_url":"https://codeload.github.com/shaunabanana/unity-websocket-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249731218,"owners_count":21317341,"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":["unity","websocket","websocket-server"],"created_at":"2024-11-16T19:18:08.794Z","updated_at":"2025-04-19T15:55:27.144Z","avatar_url":"https://github.com/shaunabanana.png","language":"C#","funding_links":[],"categories":["NetWork","Tools per Language"],"sub_categories":["C\\#"],"readme":"# unity-websocket-server\nA simple, zero-dependency WebSocket server for Unity.\n\n## Usage\nFirst import the package and set up the scene:\n* Download the UnityPackage from the [Releases page](https://github.com/shaunabanana/unity-websocket-server/releases). Import.\n* Create an empty GameObject, assign the script `WebSocketServer.cs`.\n  * Alternatively, if you're using inheritance, assign your own script.\n* Input the IP and port of the server.\n\n### In Inspector GUI\nThe easiest way is to use the inspector. Add callbacks to the `onOpen`, `onMessage`, or `onClose` UnityEvent.\n\n### Using class inheritance\nAlternatively, you can inherit from `WebSocketServer`. The following code shows you how:\n```csharp\nusing WebSocketServer;\n\npublic class MyWebSocketServer: WebSocketServer {\n\n  override public void OnOpen(WebSocketConnection connection) {\n    // Here, (string)connection.id gives you a unique ID to identify the client.\n    Debug.Log(connection.id);\n  }\n  \n  override public void OnMessage(WebSocketMessage message) {\n    // (WebSocketConnection)message.connection gives you the connection that send the message.\n    // (string)message.id gives you a unique ID for the message.\n    // (string)message.data gives you the message content.\n    Debug.Log(message.connection.id);\n    Debug.Log(message.id);\n    Debug.Log(message.data);\n  }\n  \n  override public void OnClose(WebSocketConnection connection) {\n    // Here is the same as OnOpen\n    Debug.Log(connection.id);\n  }\n\n}\n\n```\n\n## Tested on\n\u003e If you find this script works/doesn't work for you, please let me know by creating an [issue](https://github.com/shaunabanana/unity-websocket-server/issues) or emailing me at shengchenzhang1207@gmail.com.\n\u003e Also, if there's a feature you want added, there's a template for that as well in the issues.\n\n**Unity versions**\n* 2020.3\n\n**System versions**\n* macOS Big Sur (11.2.3)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaunabanana%2Funity-websocket-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaunabanana%2Funity-websocket-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaunabanana%2Funity-websocket-server/lists"}