Skip to content

ServerAPI

Greg edited this page Aug 22, 2013 · 21 revisions

cloak

Global cloak object.

cloak.configure(config)

Configuration options are given in ServerConfiguration.

Example:

cloak.configure({
  roomLife: 5000,
  messages: {
    foo: function(arg, user) {
      console.log('foo from ' + user.id);
    }
  }
});

cloak.run()

Runs the server. Call cloak.configure first!

Example:

cloak.run();

cloak.messageAll(name, arg)

The same as doing user.message(name, arg) for every connected user.

cloak.listRooms()

Return an array of all rooms.

cloak.createRoom(name, size)

Create a room. Size is the maximum number of allowed members.

cloak.deleteRoom(name)

Delete a room. All members are kicked out. If the server is configured to autoJoinLobby (as by default) the users are added to the lobby.

cloak.stop()

Stop the game loop, stop accepting new connections, disconnect all users.

Clone this wiki locally