Skip to contentGo to cookie choices
Skip to docs navigation

Multiplayer

https://docs.zokogames.com/requirements/multiplayer

Each rule here has a reason and a check you can run before you submit. Terms are in the glossary.

Multiplayer games must integrate the room and invite features. Rooms and invites need a signed-in player: for guests the calls are accepted but there is no realtime identity, so show the sign-in button before offering invites. Rooms are never available in kids mode or for a game made for children (see kids mode), and a signed-in account without a 13+ birthday on file has no realtime identity either. The guide multiplayer rooms walks through the whole flow with a runnable example.

Required integration#

  • Call updateRoom({ roomId, isJoinable, inviteParams }) whenever the player enters or changes a room. See game module.
  • Call leftRoom() when they leave.
  • If your game lets players copy a link, build it with inviteLink(params) instead of your own URL.
  • On start, read inviteParams and join the room it describes. Also register addJoinRoomListener for invites accepted while the game is open.
  • When isInstantMultiplayer is true, skip the menu and go straight into matchmaking or a lobby.

Why: the portal's friends, invites and join links work only through these calls; without them a friend cannot join. Check before submitting: the Preview and QA tab of your game ticks Multiplayer room or invite call made once your game calls updateRoom or inviteLink (it appears when Multiplayer game is ticked). Then open an invite link in a second window as a signed-in player and confirm you land in the same room. The reviewer repeats this (lobby, invites and join links; a player leaving does not freeze the room).

Playing together: the room data channel#

SDK 1.3.0 adds SDK.game.room, a small data channel between the players of one room: send(data, { to }), onMessage, a host-written shared state (setState, getState, onState), members, onMembers, isHost and onHostChange. Use it for moves, positions, ready flags and lobby settings. Limits: 8 KB per message or state patch, 20 messages per second per player (a burst of 20), 64 KB of shared state. You can still run your own server for anything bigger or authoritative; the channel does not replace one for physics or anti-cheat.

  • The platform sets the sender (from) and a sequence number and timestamp on every message; the client cannot fake them.
  • The first player to join is the host and the only one who can write the shared state. When the host leaves, the longest-standing player becomes host and onHostChange fires. Handle it: hosting duties (starting a round, keeping the counter) move with it.
  • The room holds as many players as your maximum lobby size, never more than 100 (8 when no size is set). The state is deleted when the last player leaves, and the empty room itself one minute later. A player whose connection stays down for 30 seconds leaves the room. Nothing is stored or logged.
  • It is a game data channel, not a text chat. Free text between players still needs the moderation described below, and disableChat is unaffected.

Check before submitting: open the game in two tabs in local mode (the channel is mocked through the browser), send a message from each and make the host tab leave to confirm the other tab takes over. The reference is in the game module; a complete example and the error codes are in multiplayer rooms and troubleshooting.

Flow guidance#

  • The first player in a session should land in a private, joinable room so a friend can join immediately.
  • Round-based games keep the group together between rounds instead of sending everyone back to the menu.
  • Show portal usernames in game (getUser() and the friend list), not only anonymous ids.

Lobby size#

Enter minimum and maximum players (1 to 100) on the Technical step (Minimum lobby size and Maximum lobby size); both are required for a multiplayer game, and the minimum cannot exceed the maximum. They drive the "play together" listings, and the maximum is passed to the portal as the room capacity when a room is created (capped at 100). Reviewers check that the sizes match what the game really allows. The submission cannot be sent for a multiplayer game while either size is empty.

Chat and user content#

  • Respect SDK.game.settings.disableChat fully, including hiding your own input boxes and incoming text.
  • Chat and any user-generated content need moderation: at least a profanity filter, plus a way for players to report. Unmoderated free text is rejected.
  • Never display raw HTML from other players.

Why: unmoderated free text is how a general-audience portal ends up with abuse, and children's games must have chat off. In the submission you confirm that chat is moderated. Check before submitting: set disableChat in local mode and confirm your input boxes and incoming text disappear.

Server hosting#

Real-time servers are yours. Keep the first connection fast; show matchmaking progress. If your server is down, the game must say so instead of hanging: the portal does not watch your server and shows players nothing about it, so use a connection timeout of a few seconds and a message with a Retry button. Allow the game's origin (https://g-<your-game-slug>.zokogames.com, shown with a copy button on the Technical step) in your CORS settings and in the Origin check of your WebSocket upgrade, connect over wss://, and write the host and a way to try it alone in the notes for reviewers. Check: stop your server and start the game.

Next steps#

Something unclear, wrong or missing on this page? Tell us through support · Test your game in the preview tool