GameServerOptions beta
Interface of @v12-engine/engine/server
export interface GameServerOptionsWhat 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
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
adminKey?: string;What admin messages must carry: no admin without
ai
ai?: PlayerId[];Seats the computer plays, whoever joins
autoStart
autoStart?: boolean;Starts once every seat for a player is taken, without anyone saying so. Yes when left out
cheating
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
compress?: boolean;Whether to compress what goes to players whose browsers can take it (permessage-deflate). Yes when left out
debug
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
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
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
idleTimeout?: number;Seconds a connection may say nothing, pings unanswered, before it is closed (SocketServerOptions.idleTimeout)
joinWithin
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
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
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
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
maxBuffered?: number;Bytes waiting to go out to a connection, at most, before it is closed (SocketServerOptions.maxBuffered)
maxConnections
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
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
mode: GameMode;The game the server runs: its rules, its seats and how the world of each game is made
navigationWorker
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
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
port: number;Port to listen on: 0 for any free one
rate
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
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
resultsDir?: string;Where results are kept as files, when the game has no saveResult of its own. Kept nowhere without
seat
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
sendRate?: number;How many times a second the server sends a player's screen what happened; see messageRate for the limit this implies
settings
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
stats?: number;Seconds between two lines of where the host's time goes, while a game runs: none without
watch
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
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