1.1.1 • Published 8 years ago

rpc.io v1.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

rpc.io

NPM Version

rpc over socket.io

usage

clientside:

let rpc = require('rpc.io-client')(socket, 2000);  # timeout

rpc.call('users.get', {id: 1024}) # Promise

serverside:

io.on('connection', (socket)=> {

    rpc = require("rpc.io")(socket);

    rpc.register('users.get', (id)=> {nickname: 'foo'});

    rpc.register('users', {
        delete: function*(id) {
            yield db.items.remove({owner: id});
            db.users.remove({_id: id});
        }
    });
});

optional params

rpc.register('projects.create', {description: ''}, (name, description)=>);
socket.register('projects', {
    create_defaults: {
        description: ''
    },
    create: (name, description)=>
});

handle all rpc calls

rpc.on("call", (method, kwargs)=> throw Error `method ${method} not implemented`);

handle errors

rpc.on("error", (method, kwargs, error)=> log.error(error));
1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.3

8 years ago

0.0.2

9 years ago

0.0.1

10 years ago

0.0.0

10 years ago