This document explains the base protocol all Morel games use. This protocol is followed by the default MorelClient
.
Other messages can be added for specific games.
These are included in every message (except if specified), and will not be repeated afterwards.
{
"action": "action-name",
"uuid": "the-user-assigned-uuid-or-null-to-get-one",
"secret": "the-user-assigned-secret-or-null-to-get-one",
"slug": "the-game-slug"
}
- If the
uuid
field isnull
or undefined, the server will send aset-uuid
message with an UUID and a secret, to send with every subsequent message. - If the
secret
field isnull
or undefined or invalid, and theuuid
field is set, the message will be rejected.
The client asks to join a game.
{
"pseudonym": "The requested pseudonym"
}
If the slug
is set, the server will add the player to this game if it exists; creating a new one else (either if the slug
is null
or unknown).
Will answer with set-slug
to set the game slug (if the game exists, it will be the same slug as the one sent), and with one player-join
for every player in the game (including the client that sent the message).
The client updates the configuration of the game.
{
"configuration": {}
}
The configuration object can be anything (but the server will probably check it).
If the client is not master, or if the game's state is not CONFIG
, the update will be ignored and a config-updated
message will be replied with the previous configuration to reset it.
Else, a config-updated
message will be broadcasted to the players of the game (excluding the client that sent the message), and the new configuration saved server-side.
Asks the server to (un)lock the game, preventing any new player to join. If the sender is not master, the message is ignored.
{
"locked": true
}
Asks the server to give master power to a specific player. If the sender is not master, the message is ignored.
{
"master": {
"uuid": "the new master's UUID"
}
}
Asks the server to kick a specific player. If the sender is not master, the message is ignored.
{
"kick": {
"uuid": "the kicked player's UUID"
}
}
These are included in every message, and will not be repeated afterwards.
{
"action": "action-name"
}
Sets an identifier that the client must save (only in the tab session memory; it should not persist over reloads). When the client is disconnected, when it reconnects, it should check the identifier sent and compare it with the one stored, and force-reload if they differ—this means the game server rebooted and the current game is lost.
It is also used when the player was idle in the tab out of a game for way too long, disconnected, and its server-side client reference was cleaned up.
{
"runtime_identifier": "a string identifier"
}
Sets the client's UUID, and a secret for simple auth, to be sent in every subsequent message.
{
"uuid": "the-user-assigned-uuid",
"secret": "a-secret-to-authenticate-users"
}
Sets the game's slug, to be sent in every subsequent message, and to be reflected into the URL / share box.
{
"slug": "the-game-slug"
}
Indicates that the player was kicked from the game. If locked
is true, that's because the player was unable to join at all due to the game being locked.
{
"locked": true
}
Indicates that a player joined the game. Also used when a player joins the game to send it all other already-connected players.
{
"player": {
"uuid": "8b42a578-5948-4237-8db0-cae73ff16699",
"pseudonym": "The Pseudonym",
"ready": true,
"master": false
}
}
Indicates that a player left the game.
{
"player": {
"uuid": "8b42a578-5948-4237-8db0-cae73ff16699"
}
}
Indicates that the master player has changed.
{
"master": {
"uuid":"8b42a578-5948-4237-8db0-cae73ff16699"
}
}
Indicates that the game's config has changed.
{
"configuration": {
"categories": [
"Category 1",
"Category 2"
],
"stopOnFirstCompletion": false,
"turns": 4,
"time": 180
}
}
Indicates that the game's locked (or not).
{
"locked": true
}
Indicates that a player is ready.
{
"player": {
"uuid": "the-user-assigned-uuid",
"ready": true
}
}
ready
can be true
or false
. If not provided, it defaults to true
.