five-on-it / apps/server/src/rooms
apps/server/src/rooms
Rooms: several games played at once on one game server process (TECHNICAL_SPECS §7). A RoomHost keeps a GameServer per room (its world warmed as the room opens, before anybody can join it: GameServer.warmUp), ticks them all on the one fixed loop, refuses a player when the room is full and closes a room that has stood empty for a while (never the permanent default room, the level FOI_LEVEL names, which is what a standalone server and the desktop app play).
The platform API opens a room by sending the game server a RoomOpenRequest: the room's id and where to fetch its game (and, for a public room, where its chat is moderated). openRoomFromRequest fetches the artifact (the level and the game document), checks the game against the level and the vehicle classes, and opens the room; players then connect to /rooms/<id> with a join token the API signed (index.ts), who they are (an account, a name, a party) passed on to the room. An account the room voted out is refused.
A request may name a level that ships instead of an artifact (bundled: the level and its bundled game, which the server carries, as a curated game's run needs), and a run (run-host.ts): the room then plays that one mission for the run's roster alone (another account, or a token of another run, is refused as voted out, 4403), with a quarter of the city's traffic and crowd unless the mission's play.ambient says, and it closes 15 s after the run's result, or a minute after it opened when nobody came; a run's room closed under it reports it abandoned. A live run that takes players under way lists its open seats in the room's status (open), and the platform adds a seat to it for a player it placed (RoomHost.addSeat); the run's clocks a server was given (runTiming: its seats' minute to come back, FOI_RUN_GRACE_S) go to every run's room it opens.