This file documents the websocket /api/ws ## Format Packet id then arguments \ Some packets don't have arguments so send just the packet id \ There can be multiple packets in one message, those with variable length arguments have to be terminated ## Authentication The first message from the server is: - `0x6d 0x73` The client should reply, in a single message: 1. `0xb6 0xc4` 2. client version (byte), right now it's 0 3. length of access key (byte) 4. access key, decoded from base64 Authentication complete, the server will send a disconnect if something's wrong, otherwise it will pong. \ If the client version is incorrect, the server sends a 0x01 disconnect, and doesn't verify the access key. ## Commands ### Client -> Server - `0x00` - Ping * no body * the server replies with 0x00 Pong * also a keepalive, sent by client in at most 30 second intervals otherwise the server disconnects - `0x01` - Disconnect * first there's the reason as byte, see below * second argument is a signed byte - message length in bytes * then the utf8 encoded message * after that the server doesn't wait for a reply it just closes the connection - `0x02` - Settings * setting id followed by value (length varies) terminated with 0x00 ### Server -> Client - `0x00` - Pong * the body is a single signed long (8 bytes) which the current unix time * a response to client's command of the same id ## Disconnect reasons - `0x00` - unspecified - `0x01` - incompatible client - `0x02` - timeout (client didn't send ping) - `0x03` - access key revoked - `0x04` - server error ## Settings - `0x00` - not used