bridle
v1.0.2
Published
Javscript black magic RPC over websockets.
Downloads
2
Readme
Bridle: Black magic Javascript RPC
Installation
npm install --save bridle
Bridle allows exporting functions from a Node.js server and then calling them natively from a client (both Node and browsers are supported).
Remote functions will be ran on the server, with communication occurring
using
WebSocket
transport. Local functions will be ran natively on the client as is.
Note: This project exists because it can, not because it should. The author takes no responsibility for any [mis]use.
Usage
Server:
const Bridle = require('bridle');
new Bridle.Server({
port: 7777,
localFunctions: {
foo: () => {
console.log('bar');
}
},
remoteFunctions: {
hello: (name) => 'Hello ' + name
}
});
Client:
import {Client} from 'bridle';
const rpc = new Client();
rpc.connect('ws://localhost:7777')
.then(functions => {
functions.foo();
functions.hello('world!').then(result => {
console.log(result);
}).catch(error => {
console.log(error);
});
});
Output:
$ bar
$ Hello world!
Support
Tested in Node.js v6.10.0, Chrome 63
License
ISC