Skip to main content
Devices, applications, and the Melody server talk to each other over WebSocket. A WebSocket stream is a continuous flow of bytes, so every discrete message is wrapped in a small binary frame — the HapticFrame.
The Protobuf schema and the Go, Python and JavaScript client examples live in a private repository. Ask support for access — this page carries everything needed to read and write frames without it.

Frame Layout

  • Header — one byte, the FrameType.
  • Length — uint16, little-endian, counting the full frame (header + length + data).
  • Data — a marshaled Protobuf message, at most 1018 bytes, so the whole frame stays within 1021 bytes. Split anything larger across frames.
Note that Length is written on the wire as the total frame size, so a reader subtracts headerLength to get the size of the payload that follows.

Frame Types

The first byte is the frame type. 0 is never sent; values 6-9 and 15 are retired and will not appear on the wire. A reader that meets an unknown type should skip the frame rather than fail: new types are added over time, and every frame carries its own length.

Constants and Errors


Read

Any byte other than UNKNOWN (0) is accepted as a frame type, so a reader stays forward compatible with frame types added later. Match the received FrameType against the FrameType enum in the Protobuf schema to decide how to decode Data.

Write

Empty frames are rejected: a frame carrying no payload has length == headerLength, which returns an error.
Once you can read and write HapticFrames, you can exchange any message the protocol defines. Messages are encoded with Protobuf. Continue with the Subscription Flow.