Skip to content
node.js/browser protobuf rpc over binary websockets
TypeScript Makefile JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Version 1.3.0 Jun 30, 2018
examples
protocol
src Fix typedefs Dec 25, 2017
test Fix tests not exiting Dec 25, 2017
.gitignore Update painter example Apr 30, 2017
.travis.yml Only test node 8 and 10 Jun 30, 2018
LICENSE Document things Apr 29, 2017
Makefile Tweak Makefile May 6, 2017
README.md
package-lock.json
package.json Version 1.3.0 Jun 30, 2018
tsconfig.json Initial Apr 28, 2017
tslint.json Initial Apr 28, 2017
ws-browser.js

README.md

wsrpc Build Status Coverage Status Package Version License

node.js/browser protobuf rpc over binary websockets.


Minimal example

my-service.proto

service MyService {
    rpc SayHello (HelloRequest) returns (HelloResponse) {}
}

message HelloRequest {
    required string name = 1;
}

message HelloResponse {
    required string text = 1;
}

server.js

const wsrpc = require('wsrpc')
const protobuf = require('protobufjs')

const proto = protobuf.loadSync('my-service.proto')

const server = new wsrpc.Server({
    port: 4242,
    service: proto.lookupService('MyService')
})

server.implement('sayHello', async (request) => {
    return {text: `Hello ${ request.name }!`}
})

client.js

const wsrpc = require('wsrpc')
const protobuf = require('protobufjs')

const proto = protobuf.loadSync('my-service.proto')

const client = new wsrpc.Client('ws://localhost:4242', proto.lookupService('MyService'))

const response = await client.service.sayHello({name: 'world'})
console.log(response) // Hello world!
You can’t perform that action at this time.