The other players
As soon as you get in, you receive the otherPlayers list in the welcome. From that moment on you receive a message every time something changes.
Who is already there: otherPlayers
Every item of otherPlayers has playerId, username, x and y, plus the facing fields of the mode: facing in tile, facing and angle in 8 directions, nothing in platform.
Who joins: player-joined
When another player gets in, the others who are already inside receive (not you, you already have your welcome):
{ "type": "player-joined", "playerId": "…", "username": "luigi", "x": 320, "y": 320, "facing": 90 }The facing fields follow the mode: facing in tile, facing and angle in 8 directions, nothing in platform.
Who moves: player-moved
player-moved goes to everyone, also to whoever moved. The shape depends on the mode; you find it in the Moving, by mode page. The message does not repeat the name: you already had it from the welcome or from player-joined.
Who turns: player-turned
Only in tile: when a player turns on the spot, everyone receives player-turned with playerId and facing.
Who leaves: player-disconnected
When a player goes away, all the others receive, in every mode:
{ "type": "player-disconnected", "playerId": "…" }Your client takes that player off the screen.
The order of the messages
- The newcomer receives
welcomefirst. After that, the others receiveplayer-joined. - The name (
username) arrives only in thewelcomeand inplayer-joined. - If an account gets in while it is already connected, the others see
player-disconnectedof the old connection and right awayplayer-joinedof the new one, with the sameplayerId.