Protocol reference
Wire format. Client → server: { "action": "<name>", "data": { ... } }. Server → client: { "event": "<name>", "data": ..., "timestamp": <ms> }. Errors: { "event": "error", "code": "...", "message": "..." }.
Actions
| Action | Data | Who | Reply / effect |
|---|---|---|---|
joinRoom | roomName*, maxPlayers, isVisible, isOpen, customProperties | any | roomJoined; others get playerJoined |
leaveRoom | in room | roomLeft; others get playerLeft (+ hostChanged) | |
listRooms | limit (≤50), nextToken | any | roomList { rooms, nextToken } |
getRoomState | in room | roomState { room, players } | |
setRoomProperties | properties* (object) | master | all get roomPropertiesChanged |
setPlayerProperties | properties* (object) | in room | all get playerPropertiesChanged |
sendToRoom | eventName*, data, includeSelf | in room | others get message |
sendToPlayer | targetPlayerId*, eventName*, data | in room | target gets directMessage |
sendToMaster | eventName*, data | in room | master gets message |
updatePosition | x*, y*, z*, rotation, animState | in room | others get positionUpdate |
raiseTurnEvent | eventCode*, data, targetPlayerIds | in room | eventRaised to targets, or to all others |
setTurn | targetPlayerId* | master | all get turnChanged |
endGame | results | master | all get gameEnded |
ping | any | pong |
* required. "in room" means you must have joined a room first (NOT_IN_ROOM otherwise).
Events
roomJoined, roomLeft, roomList, roomState, playerJoined, playerLeft, hostChanged, roomPropertiesChanged, playerPropertiesChanged, message, directMessage, positionUpdate, eventRaised, turnChanged, gameEnded, pong, error. Payloads are in Messaging and events.
Error codes
| Code | Meaning | Typical fix |
|---|---|---|
AUTH_FAILED | Connection record not found (for example it expired) | Reconnect |
NOT_IN_ROOM | Action needs a room | joinRoom first |
ALREADY_IN_ROOM | joinRoom while in a room | leaveRoom first |
ROOM_FULL | Room is at capacity or closed | Pick another room |
ROOM_NOT_FOUND | Room no longer exists | Rejoin |
NOT_HOST | Only the master can do this | Ask the master (sendToMaster) |
PLAYER_NOT_FOUND | Target is not in your room | Check the playerId |
INVALID_PAYLOAD | Missing or malformed field | Fix the data |
PLAN_LIMIT_EXCEEDED | App is at its room limit | Raise maxRooms or clear rooms |
RATE_LIMITED | More than 30 in-room messages in a second | Send less often |
INTERNAL_ERROR | Server-side problem; retry | Retry; contact support if it persists |
Limits and timing
| What | Value |
|---|---|
| Players per room | ≤ 50 (and ≤ app maxPlayersPerRoom) |
| Rate limit | 30 in-room messages / second / connection |
| Connections per app | Free 500 · Pro 5,000 · Enterprise unlimited · per-app override (0 = unlimited) |
listRooms page | default 20, max 50 |
| SDK heartbeat | ping every 30 s, 5 s to answer |
| SDK request timeout | 5 s |
Connect URL
wss://ws.riffserver.com?appId=<appId>&playerId=<playerId>&playerName=<name>[&token=<exp>.<hmac>]
See Connecting and master for what can refuse a connection and how tokens are signed.