4.0.2 • Published 12 months ago

nydus-client v4.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
12 months ago

nydus-client

WebSocket client library for the nydus protocol, a simple RPC/PubSub protocol.

NPM

NPM

Usage

import nydusClient from 'nydus-client'

const socket = nydusClient(host, options)

Create a nydus client and connect it to a particular host. An optional options object can be passed as the second argument. For the list of acceptable options, check the constructor method of engine.io-client.

API

socket.connect()

Connect to the server. If already connected, this will be a no-op.

socket.registerRoute(pathPattern, handler)

Register a handler function to respond to PUBLISH messages on a path matching the specified pattern. Handler function is a normal function of the form: function({ route, params, splats }, data)

PUBLISH messages that don't match a route will be emitted as an 'unhandled' event on this object, which can be useful to track in development mode.

socket.invoke(path, data)

Invoke a remote method on the server, specified via a path. Optionally, data can be specified to send along with the call (will be JSON encoded). A Promise will be returned; resolved or rejected with the result or error, respectively, from the server.

socket.disconnect()

Disconnect from the server. If not already connected, this will be a no-op.

License

MIT

4.0.2

12 months ago

4.0.0

2 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.2

5 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago