ServerEngine

ServerEngine

ServerEngine is the main server-side singleton code. Extend this class with your own server-side logic, and start a single instance.

This class should not be used to contain the actual game logic. That belongs in the GameEngine class, where the mechanics of the gameplay are actually implemented. The ServerEngine singleton is typically a lightweight implementation, logging gameplay statistics and registering user activity and user data.

The base class implementation is responsible for starting the server, initiating each game step, accepting new connections and dis-connections, emitting periodic game-state updates, and capturing remote user inputs.

Constructor

new ServerEngine(io, gameEngine, options)

create a ServerEngine instance

Parameters:
Name Type Description
io SocketIO

the SocketIO server

gameEngine GameEngine

instance of GameEngine

options Object

server options

Properties
Name Type Default Description
stepRate Number

number of steps per second

updateRate Number

number of steps in each update (sync)

tracesPath String

path where traces should go

updateOnObjectCreation Boolean

should send update immediately when new object is created

timeoutInterval Number 180

number of seconds after which a player is automatically disconnected if no input is received. Set to 0 for no timeout

Source:

Members

serializer :GameEngine

reference to game engine

Source:

Methods

gameStatus() → {String}

Report game status This method is only relevant if the game uses MatchMaker functionality. This method must return the game status.

Source:
Returns:

Stringified game status object.

Type
String