Class: WebsocketRouterUser

WebsocketRouterUser(socket, router)

Class for individual users connected via websocket to the websocket router.

Constructor

new WebsocketRouterUser(socket, router)

Create a WebsocketRouterUser (normally called automatically as a response to a connect event).

Parameters:
Name Type Description
socket object

The socket that just joined the router specific room (connected).

router object

The router where the user was connecting.

Source:

Methods

disconnect(error)

Forcefully disconnects the connected users (notification will be sent).

Parameters:
Name Type Description
error Error

The error that describes the reason for disconnect.

Source:

onDisconnect(handleFn)

Sets the disconnect handle of the user.

Parameters:
Name Type Description
handleFn function

The function that will be called once the user disconnects from the service.

Source:

onMessage(handleFn)

Sets the message handle of the user.

Parameters:
Name Type Description
handleFn function

The function that will be called once the user send a message.

Source:

send(payload)

Sends a message to the connected users.

Parameters:
Name Type Description
payload object

The content object of the message (has to be stringifiable!).

Source: