Skip to main content
The Subscribe WebSocket Event command (Command Type: 11) establishes a WebSocket subscription by overriding specific WebSocket events on an existing instance in the browser’s window object.

Command Type

Command Type ID: 11

Parameters

ParameterTypeDescriptionRequired
instancestringPath to the WebSocket instance in the browser’s window objectYes
namestringA unique identifier for this WebSocket listenerYes
timeoutnumberTimeout in millisecondsYes
initialMessagestringA message to send immediately after subscribingNo
methodsToOverrideArray of stringWebSocket methods to override. Possible values: "onmessage", "onerror", "onclose", "send"No

Usage Examples

Subscribe to a Page’s WebSocket

{
  "command": "subscribe-websocket-event",
  "params": {
    "instance": "app.liveSocket",
    "name": "oddsListener",
    "timeout": 60000
  }
}

Subscribe and Override onMessage

{
  "command": "subscribe-websocket-event",
  "params": {
    "instance": "window.feedSocket",
    "name": "feedListener",
    "timeout": 30000,
    "methodsToOverride": ["onmessage"],
    "initialMessage": "{\"type\":\"subscribe\",\"channel\":\"live\"}"
  }
}