Skip to content

GameRooms ​

Class of @v12-engine/engine/server

ts
export declare class GameRooms

Many games in a process (S58): game servers that share a port, each a room reached at its name, as a server of its own would be at its port. One process, one thread: each room's games step in turn, so the rooms of a process are as many as its ticks have time for (/metrics says how long they take). A connection to a room there is not is told so and closed. Rooms are added in code (add), or made by players of the kinds it offers (kinds, POST /games) and closed once empty

Members ​

add ​

ts
add(name: string, room: RoomOptions): Promise<GameServer>;

Opens a room at a name, as rooms does: in code, while the rooms run

close ​

ts
close(options?: {
        drain?: number;
    }): Promise<void>;

Stops every room (see GameServer.close: with drain, each waits for its game, all at once), then the port

draining ​

ts
get draining(): boolean;

Whether they take no new games: stopping

kinds ​

ts
kinds(): GameKindListing[];

The kinds of game players may make a room of (kinds), by id, with their names and the settings they offer

listing ​

ts
listing(): GameListing[];

Every room's game, as a list of games says it (GET /games)

make ​

ts
make(kind: string, settings?: Record<string, string>, seat?: RoomOptions['seat']): Promise<{
        room: string;
    } | {
        refused: string;
    }>;

Makes a room of a kind it offers (kinds), with the settings asked for: what POST /games does. Its name is the kind's and a number. Refused (with why) for a kind it does not offer, too many made, or while it stops

metrics ​

ts
metrics(): Map<string, ServerMetrics>;

The numbers of each room, by its name

modes ​

ts
modes(): string[];

The modes the rooms play, each once, in their order: what the ratings are kept by (/ratings)

port ​

ts
get port(): number;

The port they share

remove ​

ts
remove(name: string): Promise<void>;

Closes a room and lets go of its name: those in it are let go

rooms ​

ts
get rooms(): ReadonlyMap<string, GameServer>;

The rooms there are now, by name

start ​

ts
static start(options: GameRoomsOptions): Promise<GameRooms>;

Starts the rooms, and resolves once they listen