Skip to content

Opcodes & Messages

WebSocket communication uses a binary protocol with typed opcodes. Each opcode tells the kernel how to process the message.

Built-in Client Opcodes

These opcodes are defined as FlatBuffers enums in protocol::fbs::Opcode:

OpcodeHandlerPurpose
Opcode_WhoAmIhandlers::whoamiGet session identity
Opcode_Ping / Opcode_Ponghandlers::ping / pongHeartbeat / keep-alive
Opcode_ClientSubscribehandlers::subscribeSubscribe to a channel
Opcode_ClientUnsubscribehandlers::unsubscribeUnsubscribe from a channel
Opcode_Publishhandlers::publishPublish to a channel
Opcode_Sendhandlers::sendSend to a specific session
Opcode_Broadcasthandlers::broadcastBroadcast to all subscribers
Opcode_CacheGethandlers::cache_getRead from distributed cache
Opcode_CacheSethandlers::cache_setWrite to distributed cache
Opcode_CacheDeletehandlers::cache_deleteDelete from distributed cache
Opcode_JobDispatchhandlers::job_dispatchDispatch a job
Opcode_Watchhandlers::watchWatch a resource
Opcode_Unwatchhandlers::unwatchStop watching
Opcode_SetQuotahandlers::set_quotaSet rate limits
Opcode_GetQuotahandlers::get_quotaGet rate limits
Opcode_NodeMetricshandlers::node_metricsRequest node metrics
Opcode_DashboardMetricshandlers::dashboard_metricsDashboard metrics

Message Format

Messages are binary-encoded using FlatBuffers. The wire format is:

[4 bytes: frame_size] [FlatBuffers Message]

The Message FlatBuffers table contains:

FieldTypeDescription
opcodeOpcodeThe message type (enum).
transaction_idUUIDUnique ID for request-response matching.
payload[uint8]Variable-length payload data.
timestampuint64Message creation timestamp.
trace_idUUIDDistributed tracing ID.
span_iduint64Tracing span ID.

The schema is defined in the repository at protocol/schema.fbs.

Custom Opcodes

Custom opcodes start at value 200 and above:

cpp
app.register_custom_handler(201, my_handler);