WebSocketClient

WebSocketClient

Web socket to enable communication as sub pub

Constructor

new WebSocketClient(optionsopt)

Source:
Parameters:
Name Type Attributes Description
options Object <optional>

options object

Properties
Name Type Attributes Default Description
uri String <optional>
ws://localhost:9500

Full URI of server to connect to

id String <optional>
UUID

Unique ID of client, defaults to random UUID

serializer Serializer <optional>

singleton with an encode and decode object to be used

Properties
Name Type Attributes Default Description
encode function <optional>
msgpack5/encode

encoder function

decode function <optional>
msgpack5/decode

decoder function

logger logger | Boolean <optional>
{logger}

Optional logger to pass in, or use a default instance of {logger} set to debug level

options Object <optional>

See WS options

Members

blacklist

Source:
Properties:
Name Type Description
blacklistNamespaces String

array of namespaces that will be filtered out in pub()

client

Source:
See:
Properties:
Name Type Description
WS Object

client

closed

Source:
Properties:
Name Type Description
connecting Boolean

client is closed

closing

Source:
Properties:
Name Type Description
connecting Boolean

client is closeing

connecting

Source:
Properties:
Name Type Description
connecting Boolean

client is connecting

id

Source:
Properties:
Name Type Description
id String

Current id of client. Defaults to random UUID()

message

Source:
Properties:
Name Type Description
message Message

open

Source:
Properties:
Name Type Description
connecting Boolean

client is open

subscribed

Source:
Properties:
Name Type Description
subscribed Array

Curret subscribed events. Defaults to ['connect']

uri

Source:
Properties:
Name Type Description
uri String

uri which client uses to connect

Methods

close() → {WebSocketClient}

Source:

close the client connection

Returns:
Type
WebSocketClient

pub(namespace, payload, callbackopt) → {WebSocketClient}

Source:

pub Publish a payload to a given event namespace

Parameters:
Name Type Attributes Default Description
namespace String

delimited namespace to publish on

payload Number | String | Object ''

the payload object to publish

callback function <optional>

optional callback for message sent

Returns:
Type
WebSocketClient

Events

close

Source:

client has closed connection

connect

Source:

client has received a connect event

Type:
  • String

ready

Source:

client has opened and is ready