All Projects → dajuric → Websocket Rpc

dajuric / Websocket Rpc

Licence: other
WebSocket RPC library for .NET with auto JavaScript client code generation, supporting ASP.NET Core

Projects that are alternatives of or similar to Websocket Rpc

Getty
a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Stars: ✭ 532 (+303.03%)
Mutual labels:  rpc, websocket
Deepstream.io
deepstream.io server
Stars: ✭ 6,947 (+5162.88%)
Mutual labels:  rpc, websocket
Grain
grain是一个极简的、组件式的RPC框架,灵活且适合渐进学习,可与任何框架整合。同时包含(系统通用多线程模型与消息通讯 || 多对多关系的分布式锁 || 基于Servlet的HTTP框架 || 基于系统通用多线程模型的Websocket框架 || 支持行级锁的多线程锁 )等组件,按需选择组件,不绑架开发者。
Stars: ✭ 577 (+337.12%)
Mutual labels:  rpc, websocket
Eureca.io
eureca.io : a nodejs bidirectional RPC that can use WebSocket, WebRTC or XHR fallback as transport layers
Stars: ✭ 341 (+158.33%)
Mutual labels:  rpc, websocket
Autobahn Js
WAMP in JavaScript for Browsers and NodeJS
Stars: ✭ 1,345 (+918.94%)
Mutual labels:  rpc, websocket
Wampsharp
A C# implementation of WAMP (The Web Application Messaging Protocol)
Stars: ✭ 355 (+168.94%)
Mutual labels:  rpc, websocket
Ws Promise Client
PROJECT MOVED: https://github.com/kdex/ws-promise
Stars: ✭ 6 (-95.45%)
Mutual labels:  rpc, websocket
Asio2
Header only c++ network library, based on asio,support tcp,udp,http,websocket,rpc,ssl,icmp,serial_port.
Stars: ✭ 202 (+53.03%)
Mutual labels:  rpc, websocket
Python Binance Chain
Binance Chain Exchange API python implementation for automated trading
Stars: ✭ 96 (-27.27%)
Mutual labels:  rpc, websocket
Just An Email
App to share files & texts between your devices without installing anything
Stars: ✭ 75 (-43.18%)
Mutual labels:  asp-net-core, websocket
Socket Mqtt
基于Netty+MQTT的高性能推送服务框架。支持普通Socket、MQTT、MQTT web socket协议。非常方便接入上层业务实现推送业务。
Stars: ✭ 314 (+137.88%)
Mutual labels:  rpc, websocket
Wampy
Websocket RPC and Pub/Sub for Python applications and microservices
Stars: ✭ 115 (-12.88%)
Mutual labels:  rpc, websocket
Hprose Nodejs
Hprose is a cross-language RPC. This project is Hprose 2.0 for Node.js
Stars: ✭ 297 (+125%)
Mutual labels:  rpc, websocket
Hydra
后端一站式微服务框架,提供API、web、websocket,RPC、任务调度、消息消费服务器
Stars: ✭ 407 (+208.33%)
Mutual labels:  rpc, websocket
Spring Dubbo Service
微服务 spring dubbo项目:dubbo rpc;druid数据源连接池;mybatis配置集成,多数据源;jmx监控MBean;定时任务;aop;ftp;测试;Metrics监控;参数验证;跨域处理;shiro权限控制;consul服务注册,发现;redis分布式锁;SPI服务机制;cat监控;netty服务代理;websocket;disconf;mongodb集成;rest;docker;fescar
Stars: ✭ 224 (+69.7%)
Mutual labels:  rpc, websocket
Impress
Enterprise application server for Node.js and Metarhia private cloud ⚡
Stars: ✭ 634 (+380.3%)
Mutual labels:  rpc, websocket
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (+0%)
Mutual labels:  rpc, websocket
Autobahn Python
WebSocket and WAMP in Python for Twisted and asyncio
Stars: ✭ 2,305 (+1646.21%)
Mutual labels:  rpc, websocket
Simplerpc
A simple and fast contractless RPC library for .NET and .NET Core
Stars: ✭ 39 (-70.45%)
Mutual labels:  rpc, asp-net-core
Autobahn Java
WebSocket & WAMP in Java for Android and Java 8
Stars: ✭ 1,467 (+1011.36%)
Mutual labels:  rpc, websocket

WebSocketRPC logo

NuGet packages version NuGet packages version NuGet packages version

WebSokcetRPC - RPC over WebSocket for .NET
WebSocket RPC library for .NET with auto JavaScript client code generation, supporting ASP.NET Core.

Tutorial: CodeProject article

Why WebSocketRPC ?

  • Lightweight
    The only dependency is JSON.NET library used for serialization/deserialization.

  • Simple
    There are only two relevant methods: Bind for binding object/interface onto a connection, and CallAsync for making RPCs.

  • Use 3rdParty assemblies as API(s)
    Implemented API, if used only for RPC, does not use anything from the library.

  • Automatic JavaScript code generation
    The JavaScript WebSocket client code is automatically generated (with JsDoc comments) from an existing .NET interface (API contract).

Samples

Check the samples by following the link above. The snippets below demonstrate the base RPC functionality.

1) .NET <- .NET

The server implements a math API containing a single function.

Server (C#)

//server's API
class MathAPI //:IMathAPI
{
    public int Add(int a, int b)
    {
        return a + b;
    }
}

...
//run the server and bind the local and remote API to a connection
Server.ListenAsync(8000, CancellationToken.None, 
                   (c, wc) => c.Bind<MathAPI>(new MathAPI()))
      .Wait(0);

Client (C#)

//server's API contract
interface IMathAPI
{
    int Add(int a, int b);
}

...
//run the client and bind the APIs to the connection
Client.ConnectAsync("ws://localhost:8000/", CancellationToken.None, 
                    (c, ws) => c.Bind<IMathAPI>())
      .Wait(0);
      
...
//make an RPC (there is only one connection)
var r = await RPC.For<IMathAPI>().CallAsync(x => Add(5, 3)); 
Console.WriteLine("Result: " + r.First()); //Output: 'Result: 8'

2) .NET <- JavaScript

The server's code is the same, but the client is written in JavaScript. The support is given by the WebSocketRPC.JS package.

Server (C#)

//the server code is the same as in the previous sample

//generate JavaScript client (file)
var code = RPCJs.GenerateCallerWithDoc<MathAPI>();
File.WriteAllText("MathAPI.js", code);

Client (JavaScript)

//init API
var api = new MathAPI("ws://localhost:8000");

//connect and excecute (when connection is opened)
api.connect(async () => {
   var r = await api.add(5, 3);
   console.log("Result: " + r);
});

3) ASP.NET Core

To 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.

class Startup
{
    public void Configure(IApplicationBuilder app, IHostingEnvironment env) 
    {
        //the MVC initialization, etc.

        //initialize web-sockets
        app.UseWebSockets();
        //define route for a new connection and bind the API
        app.MapWebSocketRPC("/mathAPI", (httpCtx, c) => c.Bind<MathAPI>(new MathAPI()));
    }
}  

Related Libraries

SimpleHTTP library - adds the HTTP listener functionality (see the article).

How to Engage, Contribute and Provide Feedback

Remember: Your opinion is important and will define the future roadmap.

  • questions, comments - Github
  • spread the word

Final word

If 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].