2.1.10 • Published 9 years ago

ws-rpc-client v2.1.10

Weekly downloads
4
License
GPL-3.0
Repository
github
Last release
9 years ago

Project moved

This project has moved here. This repository is deprecated.

ws-rpc-client

ws-rpc-client is a tiny WebSocket subprotocol that builds a request-response model onto HTML5 WebSockets using ES2015 Promises. You can use this with ES2017's await/async to simplify your WebSocket API. ws-rpc-client supports node.js and browsers. For more flexibility, please see kdex/ws-promise-server and kdex/ws-promise-client, the official server and client based on this subprotocol.

API reference

RPC.constructor(options)

Constructs a new RPC client. options is an optional object with the following properties:

  • options.timeout A global timeout (in milliseconds) after which the delivery of a message is considered to have failed. By default, a value of 1500 is assumed.

RPC.prototype.readMessage(text, fire = true)

Reads a serialized incoming message containing text and fires a specialized event if fire is truthy. Reading a message means that the RPCClient may automatically reply with MESSAGE_ACKNOWLEDGEMENT so that the Promise on the other side resolves.

  • text The serialized Message object to read
  • fire (optional) If truthy, fires an event of message.id

async RPC.prototype.send(payload)

Sends a message containing payload in order to execute a remote method. payload takes the following form:

  • payload.instruction The instruction name to invoke on the remote target
  • payload.args An array of arguments that should be provided. If you don't pass an array, the argument will be wrapped in one.
  • payload.timeout (optional) The timeout that should be used for declaring the message transmission as failed. If not provided, the default timeout is used.
  • payload.id (optional) A unique ID to tell messages apart; if not provided, a random UUID is used.
2.1.10

9 years ago

2.1.9

9 years ago

2.1.8

9 years ago

2.1.7

9 years ago

2.1.6

9 years ago

2.1.5

9 years ago

2.1.3

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago