Rate this page:

WebSocketEvents

Add the following line to your scenario code to use the events:

require(Modules.WebSocket);

Constants

CLOSE

Copy URL

Event is triggered when the WebSocket connection is closed. WebSocket.onclose will be called right before any other handlers.

Parameters

  • WebSocket close code.

  • reason:

    string

    Reason why the connection was closed.

  • wasClean:

    boolean

    Value indicating whether the connection was cleanly closed.

  • websocket:

    WebSocket

    WebSocket object that triggered the event.

ERROR

Copy URL

Event is triggered when an error occurs on the WebSocket connection. WebSocket.onerror will be called right before any other handlers.

Parameters

  • websocket:

    WebSocket

    WebSocket object that triggered the event.

MESSAGE

Copy URL

Event is triggered when a message is received by a target object. WebSocket.onmessage will be called right before any other handlers.

Parameters

  • data:

    string

    The data sent by the message emitter.

  • websocket:

    WebSocket

    WebSocket object that triggered the event.

OPEN

Copy URL

Event is triggered when the WebSocket connection is opened. WebSocket.onopen will be called right before any other handlers.

Parameters

  • websocket:

    WebSocket

    WebSocket object that triggered the event.