On this page

latest contributor to this doc

Last Edit:

@gcharang

Enable Heartbeat Streaming

API-v2stream::heartbeat::enable

Using this method, you can enable heartbeat events streaming to a specific client.

Parameter* = requiredTypeDescription
client_id
integer
default: `0`
Optional. In the case of a single client, this defaults to 0. This ID can be used to access data via http://localhost:7783/event-stream?id=1.
config
object
Optional. A standard StreamingConfig object.

The client defines its own id when opening a connection to the stream, and each client_id can only be viewed by a single client (i.e. the ?id= url param won't work in more than one browser tab).

Parameter* = requiredTypeDescription
streamer_id
string
Optional. An identifier for the data stream. This can be used later to disable streaming for the event with stream::disable.

Enable Heartbeat Events

POST
stream::heartbeat::enable
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "stream::heartbeat::enable",
  "mmrpc": "2.0",
  "params": {
    "config": {
      "stream_interval_seconds": 30
    },
    "client_id": 1
  }
}
{
    "mmrpc": "2.0",
    "result": {
        "streamer_id": "HEARTBEAT"
    },
    "id": null
}

Here is an example of the stream data you should be able to see in http://localhost:7783/event-stream?id=1 at each heatbeat:

data: {"_type":"HEARTBEAT","message":{}}

Parameter* = requiredTypeDescription
ClientAlreadyListening
string
Optional. The requested events are already being sent to the client_id
UnknownClient
string
Optional. No client has an open connection using this client_id
{
    "mmrpc": "2.0",
    "error": "UnknownClient",
    "error_path": "heartbeat",
    "error_trace": "heartbeat:35]",
    "error_type": "EnableError",
    "error_data": "UnknownClient",
    "id": null
}
{
    "mmrpc": "2.0",
    "error": "ClientAlreadyListening",
    "error_path": "heartbeat",
    "error_trace": "heartbeat:35]",
    "error_type": "EnableError",
    "error_data": "ClientAlreadyListening",
    "id": null
}