Skip to content

GameServerOptions beta ​

Interface of @v12-engine/engine/server

ts
export interface GameServerOptions

What a GameServer is made with: the mode it runs, the port, which seats the computer plays and the limits and hooks of the server

Members ​

abandonAfter ​

ts
abandonAfter?: number;

Seconds a game goes on once every player has left it, for one of them to come back with their token: then it ends, with no winner, and the server goes back to its lobby. 60 when left out; 0 ends it at once, Infinity never. A game may end itself sooner or later its own way (ServerHooks.onPlayerLeave, world.winner)

adminKey ​

ts
adminKey?: string;

What admin messages must carry: no admin without

ai ​

ts
ai?: PlayerId[];

Seats the computer plays, whoever joins

autoStart ​

ts
autoStart?: boolean;

Starts once every seat for a player is taken, without anyone saying so. Yes when left out

cheating ​

ts
cheating?: {
        kickAfter?: number;
        seconds?: number;
    };

How many refusals in how many seconds the server kicks after when there is no onCheat, and CheatReport.recent counts over. 20 in 10

compress ​

ts
compress?: boolean;

Whether to compress what goes to players whose browsers can take it (permessage-deflate). Yes when left out

debug ​

ts
debug?: boolean;

Whether the seated players may use the debug tools (debug.* commands): for a game to try things out in. No when left out

dropSilentAfter ​

ts
dropSilentAfter?: number;

Seconds of the game a player may go without saying it got what it was sent, before it is let go (SessionHostOptions.dropSilentAfter)

http ​

ts
http?: ServerHttpOptions;

The addresses on its HTTP server besides the sockets: one that says whether it is well (/health) and one with its numbers (/metrics), each to move or leave out, and a key the numbers take. See ServerHttpOptions

idleTimeout ​

ts
idleTimeout?: number;

Seconds a connection may say nothing, pings unanswered, before it is closed (SocketServerOptions.idleTimeout)

joinWithin ​

ts
joinWithin?: number;

Seconds a connection has to join (join) before it is closed: one that never does is told nothing of the lobby meanwhile, and would be kept for good, as a browser answers the pings that let go of those gone (RV38). 10 when left out; Infinity waits for ever

keptBytes ​

ts
keptBytes?: number;

Bytes of what is kept for each player to make a delta against, at most (SessionHostOptions.keptBytes): 8 MB when left out

lobbyRate ​

ts
lobbyRate?: {
        perSecond: number;
        burst: number;
    };

The lobby's messages a second a connection may send, and how many at once: a join, a seat, a name, a setting, ready, start, an admin's word. Each is told to everyone (and an admin's key tried): what is over is dropped. 4 and 20 when left out

log ​

ts
log?: ServerLog;

Where the server says what it does (seats, games, slow ticks, what went wrong), and its games with it: a logger (Logger), whose entries say what they are about by name, or a function that takes each as a line of text. Warnings and errors go to the root logger when left out

maxBuffered ​

ts
maxBuffered?: number;

Bytes waiting to go out to a connection, at most, before it is closed (SocketServerOptions.maxBuffered)

maxConnections ​

ts
maxConnections?: number;

Connections open at once, at most (SocketServerOptions.maxConnections): one more is turned away before it is a WebSocket. 1024 when left out

messageRate ​

ts
messageRate?: {
        perSecond: number;
        burst: number;
    };

Messages a second a connection may send besides its commands (rate), and how many at once: what is over is dropped, unanswered. A player's screen says it got what it was sent sendRate times a second, pings every two seconds and asks for the ground a part at a time. 100 and 200 when left out

mode ​

ts
mode: GameMode;

The game the server runs: its rules, its seats and how the world of each game is made

ts
navigationWorker?: boolean;

Whether the navigations of its worlds are built in a worker thread (S37), so that a world being made does not hold up the ticks of the games already running: yes when left out, where the engine is built (in this repository, which runs it as it is written, they are built on the server's thread). Handed to the mode's worlds (GameMode.makeWorld's context.navigation): a mode of its own passes it on

onCheat ​

ts
onCheat?: (report: CheatReport) => CheatAnswer | void;

What becomes of a player whose client sends what an honest one never does (commandRejected: a command not what it says it is, another player's unit, a unit there never was): each is counted by seat and said in the log, and this decides, from who it is, why and how many: ignore, warn (said in the log as a warning), kick (let go, their token and id no good any more) or end (the game ends, with no winner). Without, a warning each time, and a kick once there are cheating.kickAfter within cheating.seconds

port ​

ts
port: number;

Port to listen on: 0 for any free one

rate ​

ts
rate?: {
        perSecond: number;
        burst: number;
    };

Commands a second a connection may send, and how many at once: what is over the limit is dropped, and answered refused. 30 and 60

ratings ​

ts
ratings?: Ratings;

Where ratings are kept (Ratings, createRatings): the players' shown in the lobby and the list of games, and moved by every game that ends. A player is who brings the same key (join's who), or the seat hook's id

resultsDir ​

ts
resultsDir?: string;

Where results are kept as files, when the game has no saveResult of its own. Kept nowhere without

seat ​

ts
seat?: (request: SeatRequest) => SeatAnswer | Promise<SeatAnswer>;

Who sits where, decided for each who joins: for a login, a matchmaker's ticket, a seat a lobby gave, a name checked. It gets who asks (SeatRequest: their address, name, the ticket they brought and the seats free) and answers a seat, the name to use and who they are, or a refusal with a reason; it may be asynchronous, to ask a login service. Without, the first free seat, by the name sent. One who comes back with their seat's token takes it again without being asked about. Watching is still watch's

sendRate ​

ts
sendRate?: number;

How many times a second the server sends a player's screen what happened; see messageRate for the limit this implies

settings ​

ts
settings?: Record<string, string>;

The game's settings it starts with (ServerHooks.settings), in place of their defaults: the map a room was made for. Only those the game offers, with a value it offers

stats ​

ts
stats?: number;

Seconds between two lines of where the host's time goes, while a game runs: none without

watch ​

ts
watch?: boolean | {
        key: string;
    } | ((request: WatchRequest) => boolean);

Whether those who come once the seats are taken, or who ask to, may watch: they see everything, the whole map without fog and every player's resources, so a player who could watch on the side would know all the other side does. No when left out. { key } lets in who brings the key (join's key); a function decides for each who asks

watchDelay ​

ts
watchDelay?: number;

Seconds who watches a game being played sees it behind (delayed): so that a watcher cannot tell a side where the other is now. None when left out