Skip to content

RoomAPI

Greg edited this page Nov 26, 2013 · 12 revisions

room.addMember(user)

Add a user to this room. If they are already in a room, they are removed from it. Returns true if successful.

room.removeMember(user)

Remove a user from this room. They are added to the lobby if the server is configured to autoJoinLobby (default true). If the user is not in this room, nothing happens and no error occurs.

room.getMembers(json)

Returns an array of all users. If optional json argument is true, return array of {id: str, name: str} objects.

room.data

An object for you to store custom data for each room. Initially it is {} and no data is added automatically by cloak.

room.isLobby

True if the room is the lobby.

room.id

A unique id for this room.

room.name

The name set when the room was created.

room.age()

Age of this room in milliseconds

room.messageMembers(name, arg)

The same as doing user.message(name, arg) for each user in the room.

room.delete()

Deletes the room. All members are kicked out. If the server is configured to autoJoinLobby (as by default) the users are added to the lobby. Otherwise they become roomless.