The engine does not pass unstructured strings or raw binary blobs to application handlers. Everything is decoded and validated via PacketValidator against the rigid SocketPacket discriminated union.
| Type | Key Properties | Payload Schema | Engine Semantics |
|---|---|---|---|
| event | event, data, [id], [seq] | { type: "event", event: "chat", data: {...}, id?: "ack_1" } | Application message. When id is populated, peer must reply with an ack. |
| ack | id, [data], [error] | { type: "ack", id: "ack_1", data?: {...}, error?: { code, message } } | Correlated receipt acknowledging a previous event invocation. Resolves or rejects Promise. |
| error | code, message, [id], [details] | { type: "error", code: "RATE_LIMIT_EXCEEDED", message: "..." } | System or codec violation emitted directly to peer's socket.on("error") listener. |
| connect | [sessionId] | { type: "connect", sessionId?: "sess_123" } | Internal handshaking packet confirming transport upgrade. |
| disconnect | [code], [reason] | { type: "disconnect", code: 1000, reason: "Normal" } | Explicit shutdown frame informing the remote peer to close immediately. |
Connections transition strictly through deterministic states. Handlers and heartbeat listeners are unlinked cleanly upon entering CLOSED.