Websocket API
For receiving near-realtime information about the server, some API calls have a WebSocket equivalent that pushes updates as they happen. This data can all be received through a single 'API WebSocket'.
The WebSocket can be accessed through the URL
"ws://server-host:4242/ws
" (or on another port if the API port was
changed from the default of 4242). Requesting data works through GET
parameters.
Authentication for the WebSocket API must be done through the HTTP Authenticate header.
Adding the "?logs=AMOUNT
" GET parameter will send log messages in real
time, starting with AMOUNT lines of log history. Alternatively to an
amount, the value 'since:UNIXTIMESTAMP
' may be used, which starts at
the specified Unix time stamp.
Adding the "?accs=AMOUNT
" GET parameter will send access log messages
in real time, starting with AMOUNT lines of access log history.
Alternatively to an amount, the value 'since:UNIXTIMESTAMP
' may be
used, which starts at the specified Unix time stamp.
Adding the "?streams=1
" GET parameter (the value is ignored, as long
as it is non-empty) will send stream activity information in real time.
Data sent through the WebSocket is always in the form of JSON arrays. The first element of each array indicates the type of data ('log', 'access' or 'stream'). For logs, the format is:
["log", [UNIX_TIMESTAMP, "message level", "message", "streamname"]]
For access logs, the format is:
["access", [UNIX_TIMESTAMP, "session identifier", "stream name", "connector name", "hostname", SECONDS_ACTIVE, BYTES_UP_TOTAL, BYTES_DOWN_TOTAL, "tags"]]
For streams, the format is:
["stream", ["stream name", STATUS, CURRENT_VIEWERS, CURRENT_INPUTS, CURRENT_OUTPUTS]]
//Where STATUS 0=offline, 1=init, 2=boot, 3=wait, 4=ready, 5=shutdown, 6=invalid