All communication over the WebSocket connection is done through Messages, which are passed back and forth between the WebSocket client and the robot using a consistent JSON format. They have three fields, namespace
, type
, and payload
.
namespace
is used to route messages on the robot/server side, and to allow clients to specify what information they are interested in (through subscription). This allows for separation of concerns.
The type
field is used to specify what the message means. Types are scoped to namespaces, so you can safely reuse them between namespaces.
The payload
field optionally contains arbitrary text (often escaped JSON). The libraries will handle performing the escaping for you.
Messages can be sent either as responses to a specific client, or broadcast to an entire namespace (all connections that have subscribed to the namespace will receive the message).