UserEventResponseHandler interface

The handler to set user event response

Methods

fail(400 | 401 | 500, string)

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

setState(string, unknown)

Set the state of the connection

success(string | ArrayBuffer, "binary" | "text" | "json")

Return success response with data to be delivered to the client WebSocket connection.

Method Details

fail(400 | 401 | 500, string)

Return failed response and the service will close 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.

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(string | ArrayBuffer, "binary" | "text" | "json")

Return success response with data to be delivered to the client WebSocket connection.

function success(data?: string | ArrayBuffer, dataType?: "binary" | "text" | "json")

Parameters

data

string | ArrayBuffer

The payload data to be returned to the client. Stringify the message if it is a JSON object.

dataType

"binary" | "text" | "json"

The type of the payload data.