Nostradamus Predicting Maelstroms
    Wondering what’s next for npm?Check out our public roadmap! »

    websocket-rpc-stream

    0.0.15 • Public • Published

    websocket-rpc-stream

    RPC over websockets with status updates.

    Installation

    Component

    component install manuelstofer/websocket-rpc-stream

    NPM

    npm install websocket-rpc-stream

    API

    Do a RPC call:

    var RpcStream = require('websocket-rpc-stream'),
        rpc       = new RpcStream({ socket: websocket }),
        stream    = rpc.call('create hurricane', { amount: 100 });
     
    stream.on('progress', function (progress) {
        console.log(progress);
    });
     
    stream.on('done', function (result) {
        console.log(result);
    });

    Handle RPC calls:

    var RpcStream = require('websocket-rpc-stream'),
        rpc       = new RpcStream({ socket: websocket }),
     
    rpc.on('create hurricane', function (options, stream) {
     
        var butterfly  = new Butterfly(),
            hurricanes = [];
     
        for (var i = 0; i < options.amount; i++) {
            var hurricane = butterfly.flap();
            hurricanes.push(hurricane);
     
            stream.progress(i);
        }
     
        stream.done(hurricanes);
    });

    Install

    npm i websocket-rpc-stream

    DownloadsWeekly Downloads

    2

    Version

    0.0.15

    License

    MIT

    Last publish

    Collaborators

    • avatar