Version: 1.6.0

WebSocket

The WebSocket class represents websocket connections in the page.

event: 'close'#

Fired when the websocket closes.

event: 'framereceived'#

Fired when the websocket recieves a frame.

event: 'framesent'#

Fired when the websocket sends a frame.

event: 'socketerror'#

Fired when the websocket has an error.

webSocket.isClosed()#

Indicates that the web socket has been closed.

webSocket.url()#

Contains the URL of the WebSocket.

webSocket.waitForEvent(event[, optionsOrPredicate])#

  • event <string> Event name, same one would pass into webSocket.on(event).
  • optionsOrPredicate <Function|Object> Either a predicate that receives an event or an options object.
  • returns: <Promise<Object>> Promise which resolves to the event data value.

Waits for event to fire and passes its value into the predicate function. Resolves when the predicate returns truthy value. Will throw an error if the webSocket is closed before the event is fired.