{"id":19593485,"url":"https://github.com/magicblock-labs/nativewebsocket","last_synced_at":"2025-04-23T06:05:32.788Z","repository":{"id":65536596,"uuid":"594028662","full_name":"magicblock-labs/NativeWebSocket","owner":"magicblock-labs","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-19T12:18:30.000Z","size":50,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T06:05:25.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/native-websocket","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/magicblock-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-01-27T12:35:26.000Z","updated_at":"2025-03-19T12:18:34.000Z","dependencies_parsed_at":"2024-02-14T00:29:16.799Z","dependency_job_id":"e308f8cf-fb3c-41ec-a05a-94cbe5f6ab4e","html_url":"https://github.com/magicblock-labs/NativeWebSocket","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/magicblock-labs%2FNativeWebSocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2FNativeWebSocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2FNativeWebSocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2FNativeWebSocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicblock-labs","download_url":"https://codeload.github.com/magicblock-labs/NativeWebSocket/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250379797,"owners_count":21420841,"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":[],"created_at":"2024-11-11T08:39:52.908Z","updated_at":"2025-04-23T06:05:32.761Z","avatar_url":"https://github.com/magicblock-labs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeWebSocket\n\nNativeWebSocket uses a combination of [NativeWebSocket](https://github.com/endel/NativeWebSocket) and [websocket-sharp](https://github.com/sta/websocket-sharp) to work on all the tested Unity build platform (WebGL, IOS, Android, Dektop).\n\nBoth packages has been made compatible with Unity, compiling them for dotnet 2.0 and the convience interfaca make the internal implementation transparents to the users.\n\n## How to Install\n\nDrag into Unity the 4 needed files:\n\n- NativeWebSocket.dll\n- NativeWebSocket.jslib\n- websocket-sharp-latest.dll\n- NativeWebSocket.c\n\nThe files are available at the latest release: https://github.com/garbles-labs/NativeWebSocket/releases.\n\n### WebGL\n\nIf you are compiling for WebGL, add this script to any object, e.g. the main camera.\nThis ensure that the websockets callback are always executed promtly, on the main thread.\n\n```csharp\npublic class SetupMainThread : MonoBehaviour\n{   \n    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]\n    public static void Setup()\n    {\n        MainThreadUtil.Setup();\n    }\n}\n```\n\n## How to Use:\n\n\n### Creating a connection\n\n```csharp\nwebSocket = NativeWebSocket.WebSocket.Create(\"wss://api.mainnet-beta.solana.com:443\");\n```\n\n### Opening the connection, sending and receive messages\n\n```csharp\nwebSocket.OnOpen += () =\u003e\n{\n    Debug.Log(\"Connection open!\");\n    string accountSubscribeParams =\n        \"{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"id\\\":\" + 0 +\n        \",\\\"method\\\":\\\"accountSubscribe\\\",\\\"params\\\":[\\\"\" + acc.Key +\n        \"\\\",{\\\"encoding\\\":\\\"jsonParsed\\\",\\\"commitment\\\":\\\"confirmed\\\"}]}\";\n    webSocket.Send(System.Text.Encoding.UTF8.GetBytes(accountSubscribeParams)).RunSynchronously();\n};\nwebSocket.OnMessage += bytes =\u003e\n{\n    var message = System.Text.Encoding.UTF8.GetString(bytes);\n    Debug.Log(\"SocketMessage:\" + message);\n};\nwebSocket.OnClose += (e) =\u003e Debug.Log(\"Connection closed!\");\nwebSocket.Connect();\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicblock-labs%2Fnativewebsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicblock-labs%2Fnativewebsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicblock-labs%2Fnativewebsocket/lists"}