{"id":33179916,"url":"https://github.com/dajuric/websocket-rpc","last_synced_at":"2025-11-20T21:02:05.352Z","repository":{"id":74206566,"uuid":"106484744","full_name":"dajuric/websocket-rpc","owner":"dajuric","description":"WebSocket RPC library for .NET with auto JavaScript client code generation, supporting ASP.NET Core","archived":true,"fork":false,"pushed_at":"2018-10-15T13:08:58.000Z","size":1551,"stargazers_count":142,"open_issues_count":3,"forks_count":22,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-10-26T05:34:52.521Z","etag":null,"topics":["asp-net-core","dotnet","javascript-client","rpc","websocket"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dajuric.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":"2017-10-11T00:11:32.000Z","updated_at":"2025-10-07T06:07:44.000Z","dependencies_parsed_at":"2024-02-18T03:00:30.550Z","dependency_job_id":null,"html_url":"https://github.com/dajuric/websocket-rpc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dajuric/websocket-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dajuric%2Fwebsocket-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dajuric%2Fwebsocket-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dajuric%2Fwebsocket-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dajuric%2Fwebsocket-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dajuric","download_url":"https://codeload.github.com/dajuric/websocket-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dajuric%2Fwebsocket-rpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285511776,"owners_count":27184237,"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","status":"online","status_checked_at":"2025-11-20T02:00:05.334Z","response_time":54,"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":["asp-net-core","dotnet","javascript-client","rpc","websocket"],"created_at":"2025-11-16T03:00:37.817Z","updated_at":"2025-11-20T21:02:05.339Z","avatar_url":"https://github.com/dajuric.png","language":"C#","funding_links":[],"categories":["Tools per Language"],"sub_categories":["C\\#"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Deploy/Logo/Logo-big.png\" alt=\"WebSocketRPC logo\" width=\"120\" align=\"center\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.nuget.org/packages/WebsocketRPC.Standalone/\"\u003e \u003cimg src=\"https://img.shields.io/badge/WebSokcetRPC.Standalone-v1.x-blue.svg?style=flat-square\" alt=\"NuGet packages version\"/\u003e  \u003c/a\u003e\n    \u003ca href=\"https://www.nuget.org/packages/WebsocketRPC.JS/\"\u003e \u003cimg src=\"https://img.shields.io/badge/WebSokcetRPC.JS-v1.x-blue.svg?style=flat-square\" alt=\"NuGet packages version\"/\u003e  \u003c/a\u003e\n    \u003ca href=\"https://www.nuget.org/packages/WebsocketRPC.AspCore/\"\u003e \u003cimg src=\"https://img.shields.io/badge/WebSokcetRPC.AspCore-v1.x-blue.svg?style=flat-square\" alt=\"NuGet packages version\"/\u003e  \u003c/a\u003e\n\u003c/p\u003e\n\n**WebSokcetRPC** - RPC over WebSocket for .NET    \nWebSocket RPC library for .NET with auto JavaScript client code generation, supporting ASP.NET Core.\n\n \u003e **Tutorial:** \u003ca href=\"https://www.codeproject.com/Articles/1210957/Introducing-Lightweight-WebSocket-RPC-Library-for\" target=\"_blank\"\u003eCodeProject article\u003c/a\u003e\n\n\n## Why WebSocketRPC ?\n\n+ **Lightweight**   \nThe only dependency is \u003ca href=\"https://www.newtonsoft.com/json\"\u003eJSON.NET\u003c/a\u003e library used for serialization/deserialization.\n\n+ **Simple**   \nThere are only two relevant methods: **Bind** for binding object/interface onto a connection, and **CallAsync** for making RPCs.\n\n+ **Use 3rdParty assemblies as API(s)**   \nImplemented API, *if used only for RPC*, does not use anything from the library.\n\n+ **Automatic JavaScript code generation**  \n The JavaScript WebSocket client code is automatically generated **_(with JsDoc comments)_** from an existing .NET interface (API contract).\n\n \n## \u003ca href=\"Samples/\"\u003e Samples\u003c/a\u003e\n\nCheck the samples by following the link above. The snippets below demonstrate the base RPC functionality.\n\n#### 1) .NET \u003c- .NET\nThe server implements a math API containing a single function.\n\n**Server** (C#)\n ``` csharp\n//server's API\nclass MathAPI //:IMathAPI\n{\n     public int Add(int a, int b)\n     {\n         return a + b;\n     }\n}\n\n...\n//run the server and bind the local and remote API to a connection\nServer.ListenAsync(8000, CancellationToken.None, \n                    (c, wc) =\u003e c.Bind\u003cMathAPI\u003e(new MathAPI()))\n       .Wait(0);\n ``` \n \n**Client** (C#)\n``` csharp\n//server's API contract\ninterface IMathAPI\n{\n    int Add(int a, int b);\n}\n\n...\n//run the client and bind the APIs to the connection\nClient.ConnectAsync(\"ws://localhost:8000/\", CancellationToken.None, \n                    (c, ws) =\u003e c.Bind\u003cIMathAPI\u003e())\n      .Wait(0);\n      \n...\n//make an RPC (there is only one connection)\nvar r = await RPC.For\u003cIMathAPI\u003e().CallAsync(x =\u003e Add(5, 3)); \nConsole.WriteLine(\"Result: \" + r.First()); //Output: 'Result: 8'\n ``` \n\n#### 2) .NET \u003c- JavaScript\nThe server's code is the same, but the client is written in JavaScript. The support is given by the *WebSocketRPC.JS* package.\n\n**Server** (C#)\n ``` csharp\n//the server code is the same as in the previous sample\n\n//generate JavaScript client (file)\nvar code = RPCJs.GenerateCallerWithDoc\u003cMathAPI\u003e();\nFile.WriteAllText(\"MathAPI.js\", code);\n ``` \n\n **Client** (JavaScript)\n  ``` javascript\n//init API\nvar api = new MathAPI(\"ws://localhost:8000\");\n\n//connect and excecute (when connection is opened)\napi.connect(async () =\u003e {\n     var r = await api.add(5, 3);\n     console.log(\"Result: \" + r);\n});\n ``` \n \n#### 3) ASP.NET Core\nTo incorporate server's code into the ASP.NET Core use *WebSocketRPC.AspCore* package. The initialization is done in a startup class in the *Configure* method. Everything the rest is the same.\n\n ``` csharp\nclass Startup\n{\n     public void Configure(IApplicationBuilder app, IHostingEnvironment env) \n     {\n         //the MVC initialization, etc.\n\n         //initialize web-sockets\n         app.UseWebSockets();\n         //define route for a new connection and bind the API\n         app.MapWebSocketRPC(\"/mathAPI\", (httpCtx, c) =\u003e c.Bind\u003cMathAPI\u003e(new MathAPI()));\n     }\n}  \n ```\n  \n## Related Libraries\n\u003ca href=\"https://github.com/dajuric/simple-http\" target=\"_blank\"\u003eSimpleHTTP library\u003c/a\u003e - adds the HTTP listener functionality \u003ca href=\"https://www.codeproject.com/Articles/1210957/Introducing-Lightweight-WebSocket-RPC-Library-for#httpSupport\"\u003e(see the article)\u003c/a\u003e.\n\n\n## How to Engage, Contribute and Provide Feedback  \nRemember: Your opinion is important and will define the future roadmap.\n+ questions, comments - Github\n+ **spread the word** \n\n## Final word\nIf you like the project please **star it** in order to help to spread the word. That way you will make the framework more significant and in the same time you will motivate me to improve it, so the benefit is mutual.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdajuric%2Fwebsocket-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdajuric%2Fwebsocket-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdajuric%2Fwebsocket-rpc/lists"}