Skip to content

User Actions

All player actions will contain metadata generated by the platform, that identify a user and more.

The client code will only specify the type and payload.

{
  "type": "pick",
  "payload": 1,
}

However, your game-server code will see additional metadata about the room and user.

{
  "type": "pick",
  "payload": 1,
  "timeseq": 3,
  "timeleft": 29000,
  "room_slug": "HCTJM8",
  "user": { 
    "id": "iobYl", 
    "teamid": "VAD3R3" 
  }
}

Definitions

type (string)

The type must always be a string. This string value is provided by the client that you can process in your server code. Any value can be used except for reserved types.

payload (primitive|array|object)

The payload can be any primitive (boolean, int, float, string), array, or object. It is best to keep these as simple as possible. Only your server code will look at this value.

timeseq (int)

Every time a new timer is set, the sequence is incremented by 1. This helps ensure actions are only processed for the correct sequences.

timeleft (int)

If there is a timer, this will be how much timeleft in milliseconds before timer hits zero. It's a convenience so you don't have to calculate yourself.

To convert to seconds divide by 1000.

room_slug (string)

This is the ID of the game room. It's used mostly by the platform to target the correct room.

user.id (string)

The user object holds the id of the user. This is a shortid that can be used to target a player in the players object of the Game State.

user.teamid (string)

If game has teams configured, the teamid will be stored here.