ConnectResponseHandler interface

The handler to set connect event response

Methods

fail(400 | 401 | 500, string)

Return failed response and the service will reject the client WebSocket connection.

failWith(ConnectErrorResponse | MqttConnectErrorResponse)

Return failed response with MQTT response properties and the service will reject the client WebSocket connection.

setState(string, unknown)

Set the state of the connection

success(ConnectResponse | MqttConnectResponse)

Return success response to the service.

Method Details

fail(400 | 401 | 500, string)

Return failed response and the service will reject the client WebSocket connection.

function fail(code: 400 | 401 | 500, detail?: string)

Parameters

code

400 | 401 | 500

Code can be 400 user error, 401 unauthorized and 500 server error.

detail

string

The detail of the error.

failWith(ConnectErrorResponse | MqttConnectErrorResponse)

Return failed response with MQTT response properties and the service will reject the client WebSocket connection.

function failWith(response: ConnectErrorResponse | MqttConnectErrorResponse)

Parameters

response

ConnectErrorResponse | MqttConnectErrorResponse

The response for the connect event which contains either default WebPubSub or MQTT response properties.

setState(string, unknown)

Set the state of the connection

function setState(name: string, value: unknown)

Parameters

name

string

The name of the state

value

unknown

The value of the state

success(ConnectResponse | MqttConnectResponse)

Return success response to the service.

function success(response?: ConnectResponse | MqttConnectResponse)

Parameters

response

ConnectResponse | MqttConnectResponse

The response for the connect event.