Skip to main content

WebSocket OP-Codes

Yunite is routing 100% of its traffic through Cloudflare. Cloudflare terminates idle connections after 100 seconds, so our API service is regularly sending pings through an open WebSocket connection. To make it easier for you and us to differentiate between payload data and pings on the WebSocket message stream, we introduced opcodes.

All WebSocket messages have a field called op indicating the type of the message. Other contents of the message depend on this opcode.

Here's an overview of our opcodes:

OP-Code: 0

Code 0 means ping. At the moment, you don't have to respond to pings; this might change in the future. Right now, you can just drop it. The data fields contain a counter that is incremented by 1 for each ping.

Example:

{
"op": 0,
"data": 1
}

OP-Code: 1

Code 1 means payload data. This is usually what you're looking for.

warning

In our documentation, all WebSocket message schemas only define the contents of the data field. We do not specify "op": 1 explicitly anywhere but here.

Example:

{
"op": 1,
"data": {
...
}
}