Motioncube for application designers
Motion Grid Stream - WebSocket Integration Guide
This guide describes how to integrate Motion Grid Stream with your external applications using WebSocket communication.
Quick Start
1. Connect to WebSocket
ws://127.0.0.1:12349
2. Client Authorization (Optional)
If authorization is enabled in MotionCube Player settings, the client must send an authorization message within 5 seconds of connecting:
ℹ️ Authorization is disabled by default. It can be enabled in MotionCube Player settings, where you can also configure the
auth_key.
{
"command": "AUTH_REQUEST",
"auth_key": "YOUR_AUTH_KEY"
}
| Field | Type | Description |
|---|---|---|
command |
string | Must be "AUTH_REQUEST" |
auth_key |
string | Authorization key configured in MotionCube Player settings |
Success response:
{
"type": "AUTH_COMPLETED"
}
⚠️ If authorization is enabled and the client fails to send a valid
AUTH_REQUESTwithin 5 seconds, the connection will be closed.ℹ️ Authorization can be enabled/disabled in MotionCube Player settings, where you can also configure the
auth_key.
3. Wait for Ready Signal
After connecting, wait for the server to send:
{
"status": "ready",
"setting": "grid",
"data": {
"columns": 32,
"rows": 24
}
}
This message contains the current grid configuration from the server.
| Field | Type | Description |
|---|---|---|
status |
string | Always "ready" |
setting |
string | Setting type ("grid") |
data.columns |
int | Number of grid columns |
data.rows |
int | Number of grid rows |
⚠️ Do not send commands before receiving this message.
4. Start Streaming
Send start command with grid dimensions:
{"command": "start", "params": {"cols": 32, "rows": 24}}
| Parameter | Type | Description |
|---|---|---|
cols |
int | Number of columns (1-100) |
rows |
int | Number of rows (1-100) |
5. Receive Frame Data
Server streams data in this format:
{
"frame": 1,
"timestamp": 1737654321000,
"indexes": [0, 5, 12, 47]
}
| Field | Type | Description |
|---|---|---|
frame |
int | Frame counter |
timestamp |
int | Unix timestamp (ms) |
indexes |
int[] | Active cell indexes (0-based, row-major order) |
Index calculation:
index = row * cols + col
6. Stop Streaming
{"command": "stop"}
Message Reference
Client → Server
| Command | Format |
|---|---|
| Authorize | {"command": "AUTH_REQUEST", "auth_key": "KEY"} |
| Start | {"command": "start", "params": {"cols": X, "rows": Y}} |
| Stop | {"command": "stop"} |
Server → Client
| Message | Format |
|---|---|
| Auth Success | {"type": "AUTH_COMPLETED"} |
| Ready | {"status": "ready", "setting": "grid", "data": {"columns": X, "rows": Y}} |
| Frame | {"frame": N, "timestamp": T, "indexes": [...]} |
Example (Pseudocode)
ws = WebSocket.connect("ws://127.0.0.1:12351")
gridCols = 0
gridRows = 0
on ws.open:
// Send authorization if enabled in MotionCube Player
ws.send({"command": "AUTH_REQUEST", "auth_key": "YOUR_AUTH_KEY"})
on ws.message(data):
msg = JSON.parse(data)
if msg.type == "AUTH_COMPLETED":
// Authorization successful, wait for ready signal
return
if msg.status == "ready":
gridCols = msg.data.columns
gridRows = msg.data.rows
ws.send({"command": "start", "params": {"cols": gridCols, "rows": gridRows}})
if msg.frame != null:
for index in msg.indexes:
col = index % gridCols
row = index / gridCols
// Handle active cell at (col, row)
on ws.close:
// Handle disconnection
Manage Consents
Control which external services can process your data.
Essential Required
These features are essential for the proper functioning of the website and cannot be disabled.
Anonymous Analytics Required
Required for collecting aggregated statistics that help us understand how users interact with our site. Data is fully anonymous, contains no personal information, and we do not use cookies.
Extended Analytics
Allows analyzing traffic sources (where you came from), marketing campaign parameters (UTM), and navigation paths across subdomains. We use a cookie (7 days) to preserve this data.
External Media
Allows loading content from external services like YouTube or Vimeo.