UNPKG

phaser-game-server

Version:

an express.js server that creates a socket.io connection and loads the phaser-game-server-engine

56 lines (55 loc) 1.63 kB
export type GameServerConfig = { /** * port the server will listen for requests on * * defaults to 8081 */ port?: number; /** * set this to the domain from which requests will * arrive to this server to restrict to only that * handling requests from that domain * * defaults to '*' */ allowedCorsOrigin?: string; /** * an array of paths relative to the `serverRoot` used * to load the javascript files containing the `GameEngine` * and it's dependencies * * NOTE: Ecmascript modules are **NOT** supported */ scripts?: Array<string>; /** * the location to serve any static content such as * images from * * defaults to `process.cwd()/dist` */ serverRoot?: string; }; export declare class GameServer { private _parser; private _app; private _server; private _io; readonly port: number; readonly allowedCorsOrigin: string; readonly scripts: Array<string>; readonly serverRoot: string; readonly html: string; readonly index: string; static readonly DEFAULT_CONFIG: GameServerConfig; constructor(config?: GameServerConfig); /** * loads the virtual DOM hosting the game-engine scripts and starts the ExpressJs * server listening on the port specified in the `server.config.json` file * or 8081 by default for `socket.io` connections used to send / receive * messages to / from game engine clients */ startGameEngine(): void; private _loadConfig; private _validateServerRoot; private _validateScripts; }