Skip to content

five-on-it / apps/server/src/rooms / RoomHost

Class: RoomHost ​

Defined in: apps/server/src/rooms.ts:96

The rooms of one game server process.

Constructors ​

Constructor ​

new RoomHost(options?): RoomHost

Defined in: apps/server/src/rooms.ts:111

Parameters ​

options? ​
idleMs? ​

number

log? ​

(message) => void

now? ​

() => number

prepare? ​

(level) => Promise<AiStatic>

Builds a level's navigation off the loop (nav-cache.ts); without it, a room builds its own as it opens.

runTiming? ​

Partial<Record<"afkS" | "gatherS" | "countdownS" | "graceS" | "closeAfterS" | "reportForS" | "noShowS", number>>

The run's clocks every run's room gets (run-host.ts' runTimingOf: the seats' minute to come back).

Returns ​

RoomHost

Accessors ​

size ​

Get Signature ​

get size(): number

Defined in: apps/server/src/rooms.ts:321

How many rooms are open.

Returns ​

number

Methods ​

addSeat() ​

addSeat(id, seat): { seat: number; } | { refused: string; status: number; }

Defined in: apps/server/src/rooms.ts:290

Adds a seat to a room's run under way for a player the platform placed (its join token then names that seat); why not: no such room, no run in it, no seat open on that team.

Parameters ​

id ​

string

seat ​
account ​

string = ...

name ​

string = ...

party? ​

string = ...

team ​

string = ...

tier? ​

number = ...

Returns ​

{ seat: number; } | { refused: string; status: number; }


announceRestart() ​

announceRestart(seconds): void

Defined in: apps/server/src/rooms.ts:195

Tells every room's players the server restarts for maintenance in so many seconds.

Parameters ​

seconds ​

number

Returns ​

void


close() ​

close(id): boolean

Defined in: apps/server/src/rooms.ts:253

Closes a room: its players are disconnected and its world freed (a run's not ended is abandoned).

Parameters ​

id ​

string

Returns ​

boolean


closeAll() ​

closeAll(): void

Defined in: apps/server/src/rooms.ts:265

Closes every room.

Returns ​

void


count() ​

count(): number

Defined in: apps/server/src/rooms.ts:178

The rooms open and on their way (what the rooms' cap counts): those open, those opening, those whose place is held.

Returns ​

number


disconnectAll() ​

disconnectAll(code, reason): void

Defined in: apps/server/src/rooms.ts:200

Closes every player's connection in every room with a code (restarting).

Parameters ​

code ​

number

reason ​

string

Returns ​

void


get() ​

get(id): Room | undefined

Defined in: apps/server/src/rooms.ts:243

The open room with that id.

Parameters ​

id ​

string

Returns ​

Room | undefined


isOpening() ​

isOpening(id): boolean

Defined in: apps/server/src/rooms.ts:183

Whether a room of that id is on its way (opening, or its place held), not open yet.

Parameters ​

id ​

string

Returns ​

boolean


join() ​

join(id, transport, who?): JoinResult

Defined in: apps/server/src/rooms.ts:274

Puts a connection into a room as who it is, unless there is no such room, it is full, it voted them out, or it is a run's whose roster they are not on (or the token is another run's): kicked (4403) then too.

Parameters ​

id ​

string

transport ​

Transport

who? ​

Joiner = {}

Returns ​

JoinResult


levels() ​

levels(): Iterable<LevelData>

Defined in: apps/server/src/rooms.ts:248

The levels of the open rooms (the files the server serves by hash: level-files.ts).

Returns ​

Iterable<LevelData>


list() ​

list(): object[]

Defined in: apps/server/src/rooms.ts:298

Every open room, as a game server reports them.

Returns ​


open() ​

open(options): Room

Defined in: apps/server/src/rooms.ts:211

Opens a room, its world warmed before anybody can join it (GameServer.warmUp: the physics' first step and the traffic's and the crowd's coming are the room's opening, not its first player's first second; a second or two on Riverbend, held on the loop like the world's making); throws when one with that id is open. A run's no-show clock starts once the room is ready (RunHost.ready), not while its world was made.

Parameters ​

options ​

RoomOptions

Returns ​

Room


openWhenReady() ​

openWhenReady(options): Promise<Room>

Defined in: apps/server/src/rooms.ts:134

Opens a room once its level's navigation is ready (built off the loop by prepare, so the other rooms play on meanwhile); a room of that id already open or on its way is the one answered.

Parameters ​

options ​

RoomOptions

Returns ​

Promise<Room>


playerCount() ​

playerCount(): number

Defined in: apps/server/src/rooms.ts:188

The players in every room.

Returns ​

number


reserve() ​

reserve(id, run?): () => void

Defined in: apps/server/src/rooms.ts:162

Holds a room's place while it is on its way, before anything is awaited (an API request fetching its artifact, its navigation building): the caps count it from now (the rooms', RoomHost.count; a run's, RoomHost.runCount), so concurrent requests at a cap never all pass. Returns the release, called once the room opened or failed to (twice is harmless).

Parameters ​

id ​

string

run? ​

boolean = false

Returns ​

() => void


runCount() ​

runCount(): number

Defined in: apps/server/src/rooms.ts:172

The runs' rooms open and on their way (what the cap of runs counts): those open, those whose place is held.

Returns ​

number


tick() ​

tick(): void

Defined in: apps/server/src/rooms.ts:332

Ticks every room with a player in it (an empty room's world waits where it is, warmed, costing nothing, until somebody joins; so does a frozen one, whose one player paused, never a run's), moves every run on by the clock (an empty run's room too: a dropped seat's minute runs), then closes those that have stood empty for too long, and the runs' rooms whose time came.

Returns ​

void