Skip to content

Instantly share code, notes, and snippets.

@incompl
Last active December 26, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save incompl/7104384 to your computer and use it in GitHub Desktop.
Save incompl/7104384 to your computer and use it in GitHub Desktop.
cloak.configure({
// New users go to the lobby, a special
// room that exists by default.
autoJoinLobby: true,
// Create a new room automatically when there are
// enough users in the lobby. Users are added
// to the new room when it's created.
autoCreateRooms: true,
// How many people are needed before a room is
// created.
// If a room falls below 2 users, the remaining
// user is kicked back to the lobby.
minRoomMembers: 2,
// Only wait 15 seconds for a user to reconnect.
// If they reconnect in this time, they stay in
// the same room and nothing changes. Otherwise,
// they are removed from any rooms they're in.
reconnectWait: 15000,
// Rooms automatically close after 30 minutes,
// no matter what. Any users in this room would
// go back to the lobby.
roomLife: 1800000,
// Event handlers for the lobby
lobby: {
newMember: function(user) {
user.message('waitingForAnotherPlayer');
}
},
// Event handlers for normal rooms
room: {
init: function() {
this.data = new MyGame();
},
newMember: function(user) {
user.message('gameStart');
}
},
// Event handlers for messages from the client
messages: {
move: function(msg, user) {
user.getRoom().data.move();
}
}
});
cloak.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment