Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msgpack-rpc-lite

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msgpack-rpc-lite

Implementation of MessagePack-RPC with msgpack-lite

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by28.57%
Maintainers
1
Weekly downloads
 
Created
Source

msgpack-rpc-lite

npm version Build Status Codacy Badge Codacy Badge

Implementation of MessagePack-RPC with msgpack-lite

Usage

  • createServer([serverOptions][, codecOptions])

    Creates a new MessagePack-RPC server.

    • serverOptions <Object> See net.createServer([options][, connectionListener])
    • codecOptions <Object>
    • Returns: <net.Server>
  • Server event: method

    Emitted when a new connection is made.

    • <Array> request parameters.
    • <Function> If a request is received, a callback function is passed.
      • To return the results to the client, pass null as the first argument and response parameters as the second argument.
      • If an error occurs, pass it to the first argument.
  • createClient(port[, host][, timeout][, codecOptions])

    Initiates a MessagePack-RPC client.

    • port <number> Port the socket should connect to.
    • host <string> Host the socket should connect to. Default: 'localhost'
    • timeout <number> Sets the socket to timeout after timeout milliseconds of inactivity on the socket. If timeout is 0, then the existing idle timeout is disabled. Default: 0
    • codecOptions <Object>
    • Return: <Client>
  • client.request(method[, ...args])

    • method <string>
    • Return: <Promise>
  • client.notify(method[, ...args])

    • method <string>
    • Return: <Promise>

Examples

  • Server

    const rpc = require('msgpack-rpc-lite');
    const server = rpc.createServer().on('say', (params, callback) => {
        const [ message ] = params; 
        callback(null, `hello ${ message }`);
    });
    server.listen(9199);
    
  • Client

    const rpc = require('msgpack-rpc-lite');
    
    const client = rpc.createClient(9199, 'localhost');
    client.request('say', [ 'world' ]).then(([ response ]) => {
        console.log(response); // hello world
    })
    

Compatibility Mode

Set true to useraw of encode/decode of Codec-options.

  • Client
    const codecOptions = { encode: { useraw: true }, decode: { useraw: true } };
    
    const client = rpc.createClient(9199, 'localhost', 0, codecOptions);
    

See also:

See also

Keywords

FAQs

Package last updated on 19 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc