Press5.xyz

press5 Play

press5 Play protocol

JSON over WebSocket, for writing a client in any engine.

press5 Play protocol, version 2

Version 2 adds server rooms: rooms run by one of press5's engines (see "Server rooms" below). Everything in version 1 still works unchanged; send "v": 2 in hello to say you understand version 2 frames.

Connect a WebSocket to wss://play.press5.xyz/v1. Every text frame is one JSON object with a type t. A client frame may carry rid (a short string or number); the reply to it carries the same rid. Errors are {"t":"error","rid":..,"code":"...","message":"..."}. Close codes: 4001 game not allowed, 4002 no hello in 10 s, 4003 game full, 4008 rate limit, 4010 resumed elsewhere, 1012 server restart (reconnect and resume), 1009 frame too big.

Hello (first frame)

{"t":"hello","v":1,"name":"Ada","key":"p5g_...","resume":"<token>","sdk":"mylib/1.0"}

Lobby frames

Joining replies {"t":"joined","you":"<id>","resume":"<token>","room":{"code","mode","private","locked","maxPlayers", "filters","meta","host","state","players":{"<id>":{"id","name","seat","state","away","joinedAt"}},"tickRate","createdAt"}}. Joining another room leaves the current one.

Room frames (client)

Room frames (server)

Frames that change who is in the room, who is host, or messages are sent after any pending patch, so order is kept.

Binary frames

Client to server: byte 0 is the target seat (255 = everyone else), the rest is yours. The server replaces byte 0 with the sender's seat and forwards it. Counted against the same rate limits.

Server rooms (version 2)

A game whose press5.game.json has a "server" block gets one of press5's engines in every room. No game code runs on press5: the engine is press5's, the game only chooses it and sets it up. The joined frame then carries room.engine: {"name","version","tickRate","patchEvery","config"} (the full, checked settings, so a client can draw walls and predict movement). Relay set is refused (engine_room); send (chat) still works.

Client frames:

Server frames:

Deltas

d turns the previous snapshot into the new one, key by key: a key that is missing is unchanged; null means the key was removed; an object means "apply this inside"; anything else (a number, string, boolean or array) replaces the old value. Snapshots never contain null themselves.

apply(prev, d): for key, v in d:
  if v is null: delete prev[key]
  elif v is an object: prev[key] = apply(prev[key] or {}, v)
  else: prev[key] = v

arena v1

turns v1

party v1

Leaderboards

hello may carry "guest":"g1...." (the token from an earlier welcome); welcome always has "guest", which a client keeps on the device. Results of server rooms with at least two players lasting 30 s go on the game's leaderboard: GET /v1/games/{name}/leaderboard?period=all|week|day. There is no way for a client to write one. The same two players' results against each other count in full ten times a day, then half as much each time.

Datagrams: UDP and WebTransport (version 2)

For fast games, state and inputs can also travel as unreliable datagrams. Everything else stays on the WebSocket, which is always open and is the fallback.