Skip to content

ServerConfiguration

Greg edited this page May 6, 2015 · 35 revisions

These are passed to cloak.configure() before calling cloak.run() See ServerAPI for more details on running the server.

  • port to run on
  • express Express server to run on. Use instead of port. example
  • gameLoopSpeed how frequently do game loop "pulses" happen in ms. default 100
  • defaultRoomSize Maximum number of players in a room. Default null (no maximum) but can be any number 1 or greater. Set to 1 for a single player game.
  • autoJoinLobby default true. Players automatically join the lobby after connecting, when leaving a room, etc.
  • autoCreateRooms default false. create rooms as soon as there are enough users in the lobby to meet the minRoomMembers. When a room is created, players in the lobby are automatically added.
  • minRoomMembers If a room reaches minRoomMembers, then falls below that many members, the room is closed. When used with autoCreateRooms, this is the minimum number of lobby members required for a room to be created. Default null.
  • pruneEmptyRooms If a room is empty for this many milliseconds it is closed. Default null.
  • reconnectWait how long the server waits (in milliseconds) for a user to reconnect before deleting them and removing them from any rooms they're in. default 10000. set to null to wait forever
  • reconnectWaitRoomless override reconnectWait for users that are not in a room. default null which means same as reconnectWait Note: this wait time refers to how long they have been disconnected total, not how long since they left a room.
  • roomLife how long in ms a room is open before it automatically closes. set to null for infinite. default null
  • notifyRoomChanges send roomCreated and roomDeleted server events to lobby members. default true
  • messages
    • custom events to handle messages from client. The parameters are the message argument from the client and the User object.
  • room
    • init callback on new room
    • pulse called periodically for rooms
    • newMember called when a new member joins the room. this is the room, function arg is the user
    • memberLeaves called when a member leaves the room. this is the room, function arg is the user
    • close callback on closing of room
    • shouldAllowUser function that takes a user and returns true if the user is allowed to join at this time. default is to always allow users to join rooms
  • lobby
    • has the same events as room (see above) but they only apply to the lobby
  • clientEvents
    • begin a client has connected for the first time. Argument is the user object.
    • disconnect a client has disconnected. Argument is the user object.
    • resume a client has reconnected. Argument is the user object.
  • socketIo
    • You can pass through socket.IO server configuration options here.
Clone this wiki locally