# Class: WebsocketRouterUser

## WebsocketRouterUser

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

#### 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.

### 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.

#### 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.

#### 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.

#### 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!).

#### Search results