Skip to content

UserAPI

Greg edited this page Aug 26, 2014 · 15 revisions

Users are created automatically by Cloak on new connections and can be retrieved with cloak.getUsers() or room.getMembers()

user.message(name, arg)

Send a message to this user. The message handler on the client is called if there is one for this message name.

user.id

A unique ID for this user

user.name

Defaults to "Nameless User"

user.data

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

user.connected()

Returns true if the user is currently connected, otherwise false

user.joinRoom(room)

Enter a room

user.leaveRoom()

User leaves the room they're currently in, if they are in one. They return to the lobby if the server is configured to autoJoinLobby (default is true)

user.getRoom()

Get the Room that this user is in.

user.delete()

User is kicked from any rooms they're in and is disconnected.