Package | net.user1.reactor |
Class | public class RoomManager |
Inheritance | RoomManager ![]() |
Since : | Reactor 1.0.0 |
reactor.getRoomManager()
reactor.getRoomManager().getRoom("examples.chat");
var room:Room = reactor.getRoomManager().createRoom("examples.chat"); room.join();
See also
Method | Defined By | ||
---|---|---|---|
RoomManager(reactor:Reactor)
Constructor
| RoomManager | ||
clientIsKnown(clientID:String):Boolean
Returns true if the client with the specified clientID is an occupant
or observer of any of the room manager's currently known rooms. | RoomManager | ||
createRoom(roomID:String = null, roomSettings:RoomSettings = null, attributes:XML = null, modules:RoomModules = null):Room
The createRoom() method creates a new Room object on the client and
attempts to create the matching room on the server. | RoomManager | ||
disposeCachedRooms():void
Forcibly removes all rooms from this RoomManager's room cache. | RoomManager | ||
getNumRooms(qualifier:String = null):int
Returns the number of rooms with the specified qualifier currently known
to the RoomManager. | RoomManager | ||
Returns a reference to the Room instance specified by roomID. | RoomManager | ||
Returns the RoomManager's RoomClassRegistry object, which catalogs all
client-side room classes. | RoomManager | ||
getRoomIDs():Array
Returns an array of roomIDs for the Room objects known to this RoomManager. | RoomManager | ||
getRooms():Array
Returns an array of the Room objects known to this RoomManager. | RoomManager | ||
getRoomsWithQualifier(qualifier:String = null):Array
Returns an array of Room objects with the specified room qualifier. | RoomManager | ||
hasCachedRoom(roomID:String):Boolean
Returns true if the RoomManager has a Room object for the specified
roomID in its list of cached rooms; otherwise, returns false. | RoomManager | ||
hasObservedRoom(roomID:String):Boolean
Returns true if the current client is known to be observing the specified room;
otherwise, returns false. | RoomManager | ||
hasOccupiedRoom(roomID:String):Boolean
Returns true if the current client is known to be in the specified room;
otherwise, returns false. | RoomManager | ||
hasWatchedRoom(roomID:String):Boolean
Returns true if the RoomManager has a Room object for the specified
roomID in its watched rooms list; otherwise, returns false. | RoomManager | ||
isWatchingQualifier(qualifier:String):Boolean
Indicates whether the current client is currently watching the
specified qualifier. | RoomManager | ||
Asks the server to place the current client in the server-side room. | RoomManager | ||
The observeRoom() method provides a means for a client to spectate a
room's state and activity without actually being in that room. | RoomManager | ||
removeRoom(roomID:String, password:String = null):void
Asks the server to remove the specified room. | RoomManager | ||
roomIsKnown(roomID:String):Boolean
Returns true if the specified room is known to the RoomManager. | RoomManager | ||
sendMessage(messageName:String, rooms:Array, includeSelf:Boolean = false, filters:IFilter = null, ... rest):void
Sends a message to clients in the room(s) specified by
rooms. | RoomManager | ||
stopWatchingForRooms(roomQualifier:String = null):void
Asks the server to stop watching for rooms. | RoomManager | ||
watchForRooms(roomQualifier:String = null):void
Asks the server to send a notification any time a room with the
specified qualifier is created or removed. | RoomManager |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when the server reports the result of an attempt to create a room by the current client. | RoomManager | |||
Dispatched when the result of an earlier room-join request by the current client is received. | RoomManager | |||
Dispatched when the result of an earlier room-leave request by the current client is received. | RoomManager | |||
Dispatched when the result of an earlier observe-room request by the current client is received. | RoomManager | |||
Dispatched when the server reports the result of a remove-room attempt by the current client. | RoomManager | |||
Dispatched when the current client gains knowledge of a new room. | RoomManager | |||
Dispatched whenever the RoomManager gains or loses knowledge of a room, as described under RoomManagerEvent.ROOM_ADDED and RoomManagerEvent.ROOM_REMOVED. | RoomManager | |||
Dispatched when the current client loses knowledge of a new room. | RoomManager | |||
Dispatched when the result of an earlier stop-observing-room request by the current client is received. | RoomManager | |||
Dispatched when the server reports the result of a stop-watching-for-rooms attempt by the current client. | RoomManager | |||
Dispatched when the server reports the result of a watch-for-rooms attempt by the current client. | RoomManager |
RoomManager | () | Constructor |
public function RoomManager(reactor:Reactor)
Constructor
Parametersreactor:Reactor — The Reactor instance that created this RoomManager.
|
clientIsKnown | () | method |
public function clientIsKnown(clientID:String):Boolean
Since : | Reactor 1.0.0 |
Returns true if the client with the specified clientID is an occupant or observer of any of the room manager's currently known rooms.
Parameters
clientID:String |
Boolean |
See also
createRoom | () | method |
public function createRoom(roomID:String = null, roomSettings:RoomSettings = null, attributes:XML = null, modules:RoomModules = null):Room
Since : | Reactor 1.0.0 |
The createRoom() method creates a new Room object on the client and
attempts to create the matching room on the server.
If roomID
is specified, the new room is given the supplied
identifier; otherwise, the server generates the room's identifier
automatically. The result of the room-creation attempt is returned via a
RoomManagerEvent.CREATE_ROOM_RESULT event.
Parameters
roomID:String (default = null ) — The fully qualified id of the new room, as a string. For
example, "examples.chat". If roomID is not
specified, the room id will be generated automatically by the server and
returned via RoomManagerEvent.CREATE_ROOM_RESULT.
| |
roomSettings:RoomSettings (default = null ) — A RoomSettings object containing the initial settings
for the new room. For details, see the RoomSettings class.
| |
attributes:XML (default = null ) — An XML object that describes the initial room
attributes for the room in the following format:
<ATTRIBUTES> <ATTRIBUTE> <NAME>attrName</NAME> <VALUE>attrValue</VALUE> <SHARED>true|false</SHARED> <PERSISTENT>true|false</PERSISTENT> <IMMUTABLE>true|false</IMMUTABLE> </ATTRIBUTE> </ATTRIBUTES> | |
modules:RoomModules (default = null ) — A RoomModules object specifying the server-side modules
for the room. For details, see the RoomModules class.
|
Room — If the roomID parameter is not null, returns a Room object
representing the room the client wishes to create. If the roomID parameter
is null, returns null (in which case, the current client is expected to
retrieve access to the room after the dynamically generated roomID
has been returned via RoomManagerEvent.CREATE_ROOM_RESULT).
|
See also
var settings:RoomSettings = new RoomSettings(); settings.removeOnEmpty = false; settings.maxClients = 50; var room:Room = connection.getRoomManager().createRoom(roomID, settings);
disposeCachedRooms | () | method |
public function disposeCachedRooms():void
Since : | Reactor 1.0.0 |
Forcibly removes all rooms from this RoomManager's room cache. Rooms are potentially added to the room cache in the following situations:
reactor.getRoomManager().joinRoom("examples.chat");
See also
getNumRooms | () | method |
public function getNumRooms(qualifier:String = null):int
Since : | Reactor 1.0.0 |
Returns the number of rooms with the specified qualifier currently known to the RoomManager. Rooms that exist on the server but are unknown to the client-side room manager are not reflected in the value returned by getNumRooms(). To synchronize the RoomManager with the server's room list, use watchForRooms() (which automatically keeps the RoomManager synchronized with the server's room list).
Parameters
qualifier:String (default = null ) — Specifies the qualifier for which a room count should be
returned. For example, getNumRooms("example") returns
the number of rooms with roomIDs qualified by "example".
If qualifier is omitted, getNumRooms() returns the
total number of rooms known to the RoomManager.
|
int — An integer specifying the number of rooms with the specified
qualifier known to the RoomManager.
|
See also
getRoom | () | method |
public function getRoom(roomID:String):Room
Since : | Reactor 1.0.0 |
Returns a reference to the Room instance specified by roomID. If no such Room instance exists, returns null.
Parameters
roomID:String — The fully qualified identifier of the Room object
to retrieve.
|
Room |
reactor.getRoomManager().getRoom("chatrooms.sportschat");
getRoomClassRegistry | () | method |
public function getRoomClassRegistry():RoomClassRegistry
Since : | Reactor 1.0.0 |
Returns the RoomManager's RoomClassRegistry object, which catalogs all client-side room classes.
ReturnsRoomClassRegistry |
See also
getRoomIDs | () | method |
public function getRoomIDs():Array
Since : | Reactor 1.0.0 |
Returns an array of roomIDs for the Room objects known to this RoomManager. The array is a one-time copy of the roomIDs in the RoomManager's known room list, and is not updated after the call to getRoomIDs(). To retrieve an array of Room instances instead of room IDs, use RoomManager's getRooms() method.
ReturnsArray — An array of string room ids.
|
See also
getRooms | () | method |
public function getRooms():Array
Since : | Reactor 1.0.0 |
Returns an array of the Room objects known to this RoomManager. The list includes rooms the RoomManager has confirmed as existing only, and does not include any rooms the RoomManager has speculatively created in anticipation of incomplete operations such as a joinRoom() call. The array is a one-time copy of the RoomManager's known room list, and is not updated after the call to getRooms().
ReturnsArray |
See also
getRoomsWithQualifier | () | method |
public function getRoomsWithQualifier(qualifier:String = null):Array
Since : | Reactor 1.0.0 |
Returns an array of Room objects with the specified room qualifier. The array is a one-time snapshot, and is not updated after the call to getAllRooms(). If no qualifier is specified, returns all rooms (identical to getRooms()).
Parameters
qualifier:String (default = null )
|
Array — An array containing Room instances (or instances of
subclasses of Room.
|
See also
hasCachedRoom | () | method |
public function hasCachedRoom(roomID:String):Boolean
Since : | Reactor 1.0.0 |
Returns true if the RoomManager has a Room object for the specified roomID in its list of cached rooms; otherwise, returns false. See watchForRooms().
Parameters
roomID:String — A fully qualified room id, such as "examples.chat".
|
Boolean |
See also
hasObservedRoom | () | method |
public function hasObservedRoom(roomID:String):Boolean
Since : | Reactor 1.0.0 |
Returns true if the current client is known to be observing the specified room; otherwise, returns false. See observeRoom().
Parameters
roomID:String — A fully qualified room id, such as "examples.chat".
|
Boolean |
See also
hasOccupiedRoom | () | method |
public function hasOccupiedRoom(roomID:String):Boolean
Since : | Reactor 1.0.0 |
Returns true if the current client is known to be in the specified room; otherwise, returns false. See joinRoom().
Parameters
roomID:String — A fully qualified room id, such as "examples.chat".
|
Boolean |
See also
hasWatchedRoom | () | method |
public function hasWatchedRoom(roomID:String):Boolean
Since : | Reactor 1.0.0 |
Returns true if the RoomManager has a Room object for the specified roomID in its watched rooms list; otherwise, returns false. See watchForRooms().
Parameters
roomID:String — A fully qualified room id, such as "examples.chat".
|
Boolean |
See also
isWatchingQualifier | () | method |
public function isWatchingQualifier(qualifier:String):Boolean
Since : | Reactor 1.0.0 |
Indicates whether the current client is currently watching the specified qualifier.
Parameters
qualifier:String |
Boolean |
See also
joinRoom | () | method |
public function joinRoom(roomID:String, password:String = null, updateLevels:UpdateLevels = null):Room
Since : | Reactor 1.0.0 |
Asks the server to place the current client in the server-side room. If the room is not already represented by a client-side room object, one is created and returned. When the result of the attempt is received, a RoomEvent.JOIN_RESULT event is dispatched via both the RoomManager and the joined Room. If the request attempt succeeds, a RoomEvent.JOIN event is also dispatched via the Room. The Room object will subsequently be kept updated in accordance with the current client's specified update levels (see the UpdateLevels class).
RoomManager's joinRoom() method is functionally identical to Room's join(), method, except that it can be used without the prior existence of a Room object.
Parameters
roomID:String — The fully qualified room ID of the room to join.
| |
password:String (default = null ) — The optional string password used to enter the room.
| |
updateLevels:UpdateLevels (default = null ) — Specifies the client's update levels for the room,
which dictate the amount of information the client receives
about the room while it is in or observing the room. See the
UpdateLevels class for details.
|
Room — The room being joined.
|
See also
observeRoom | () | method |
public function observeRoom(roomID:String, password:String = null, updateLevels:UpdateLevels = null):Room
Since : | Reactor 1.0.0 |
The observeRoom() method provides a means for a client to spectate a room's state and activity without actually being in that room. For example, a chat moderator client might observe a chat room to spectate the chat without actually participating in it.
When observeRoom() is invoked, the client sends a request to begin observing the specified room. If the request is successful, the corresponding client-side Room object will be synchronized with the server, and will subsequently be kept updated in accordance with its specified update levels (see the UpdateLevels class).
When an observation request for a room completes, the RoomEvent.OBSERVE_RESULT event is dispatched via the RoomManager and the observed Room. If the request succeeds, RoomEvent.OBSERVE is also dispatched via the Room.
A client can observe a room, and then join and leave it arbitrarily without affecting observation status.
RoomManager's observeRoom() method is functionally identical to Room's observe(), method, except that it can be used without the prior existence of a Room object.
Parameters
roomID:String — The fully qualified room ID of the room to observe.
| |
password:String (default = null ) — The optional string password used to observe the room.
| |
updateLevels:UpdateLevels (default = null ) — Specifies the client's update levels for the room,
which dictate the amount of information the client receives
about the room while it is in or observing the room. See the
UpdateLevels class for details.
|
Room — A reference to the room being observed, or null if the observation
request could not be sent.
|
See also
removeRoom | () | method |
public function removeRoom(roomID:String, password:String = null):void
Since : | Reactor 1.0.0 |
Asks the server to remove the specified room. The result of the attempt triggers the RoomManagerEvent.REMOVE_ROOM_RESULT event on the current client. If the removal succeeds, and there is a client-side Room object corresponding to the room in question, that Room object is automatically removed.
Clients in the room at the time of removal are automatically forced to leave the room, triggering a RoomEvent.LEAVE event.
Parameters
roomID:String — The fully qualified identifier of the room to remove.
For example, "examples.chat".
| |
password:String (default = null ) — The password required to remove the room.
|
See also
roomIsKnown | () | method |
public function roomIsKnown(roomID:String):Boolean
Since : | Reactor 1.0.0 |
Returns true if the specified room is known to the RoomManager. A room is known when the current client successfully is in or observing it, or when it is in the RoomManager's watched room list (see watchForRooms()).
Parameters
roomID:String |
Boolean |
See also
sendMessage | () | method |
public function sendMessage(messageName:String, rooms:Array, includeSelf:Boolean = false, filters:IFilter = null, ... rest):void
Since : | Reactor 1.0.0 |
Sends a message to clients in the room(s) specified by
rooms
. To send a message to clients in a single room
only, use Room's sendMessage() method.
Clients that prefer not to receive messages for a room can opt out of messages via the Room class's setUpdateLevels() method.
To receive the message, recipient clients must register a message listener via MessageManager's addMessageListener() method. For example,
msgManager.addMessageListener("CHAT_MESSAGE", centralChatListener);
The message listener must define mandatory parameters; for details, see the MessageManager class's addMessageListener() method. The following code shows an example message listener, centralChatListener() that is invoked any time a "CHAT_MESSAGE" message is sent to any room the current client is in or observing:
public function centralChatListener (fromClient:IClient, toRoom:Room, chatMessage:String):void {
To send a message to all rooms whose IDs are directly qualified by a given
qualifier (non-recursive), specify that qualifier, followed by an asterisk,
for sendMessage()'s rooms
parameter. For example, the following
code sends "CHAT_MESSAGE" to all rooms qualified by "examples".
reactor.getRoomManager().sendMessage("CHAT_MESSAGE", ["examples.], true, null, "hi there");
To send a message to all clients on the server, use the Server class's sendMessage() method.
Parameters
messageName:String — The name of the message to send.
| |
rooms:Array — The room(s) to which to send the message.
Each entry in the rooms array must be either a fully
qualified room ID, or a room ID qualifier.
| |
includeSelf:Boolean (default = false ) — Indicates whether to send the message to the current
client (i.e., the client that invoked sendMessage()).
Defaults to false (don't echo to the sender).
| |
filters:IFilter (default = null ) — Specifies one or more filters for the message. A
filter specifies a requirement that each client must
meet in order to receive the message. For example, a
filter might indicate that only those clients with
the attribute "team" set to "red" should receive the
message. For complete details, see the IFilter interface.
If filters is null, all interested clients in rooms
receive the message.
| |
... rest — An optional comma-separated list of string arguments for
the message. These will be passed to any listeners
registered to receive the message. See
Room's addMessageListener() method and MessageManager's
addMessageListener() method.
|
See also
stopWatchingForRooms | () | method |
public function stopWatchingForRooms(roomQualifier:String = null):void
Since : | Reactor 1.0.0 |
Asks the server to stop watching for rooms. In response, the server no longer sends notifications when a room with the specified roomQualifier is added or removed. The result of a stopWatchingForRooms() request is returned via a RoomManagerEvent.STOP_WATCHING_FOR_ROOMS_RESULT event.
Parameters
roomQualifier:String (default = null ) — The roomID qualifier to stop watching
(e.g., "examples.chat.sports"). To stop watching for rooms with the unnamed
qualifier, set roomQualifier to the empty string (""). To stop watching for all
rooms on the server, use null or omit roomQualifier.
|
See also
watchForRooms | () | method |
public function watchForRooms(roomQualifier:String = null):void
Since : | Reactor 1.0.0 |
Asks the server to send a notification any time a room with the specified qualifier is created or removed. The notifications trigger either a RoomManagerEvent.ROOM_ADDED event or a RoomManagerEvent.ROOM_REMOVED event. Clients typically use watchForRooms() to create an application lobby, where a dynamic list of rooms is presented to the user for selection. The result of a watchForRooms() request is returned via RoomManagerEvent.WATCH_FOR_ROOMS_RESULT.
Parameters
roomQualifier:String (default = null ) — The roomID qualifier to watch
(e.g., "examples.chat.sports"). To watch for rooms with the unnamed
qualifier, set roomQualifier to the empty string (""). To watch for all
rooms on the server, use null or omit roomQualifier.
|
See also
CREATE_ROOM_RESULT | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.CREATE_ROOM_RESULT
Dispatched when the server reports the result of an attempt to create a room by the current client. To determine the result of the attempt, use getStatus(), which has the following possible return values:
See also
JOIN_RESULT | Event |
RoomEvent
net.user1.reactor.RoomEvent.JOIN_RESULT
Dispatched when the result of an earlier room-join request by the current client is received. To determine the result of the request, use getStatus(), which has the following possible return values:
If the room-join request was successful, the RoomEvent.JOIN event will also be triggered.
See also
LEAVE_RESULT | Event |
RoomEvent
net.user1.reactor.RoomEvent.LEAVE_RESULT
Dispatched when the result of an earlier room-leave request by the current client is received. To determine the result of the request, use getStatus(), which has the following possible return values:
If the leave-join request was successful, the RoomEvent.LEAVE event will also be triggered.
See also
OBSERVE_RESULT | Event |
RoomEvent
net.user1.reactor.RoomEvent.OBSERVE_RESULT
Dispatched when the result of an earlier observe-room request by the current client is received. To determine the result of the request, use getStatus(), which has the following possible return values:
See also
REMOVE_ROOM_RESULT | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.REMOVE_ROOM_RESULT
Dispatched when the server reports the result of a remove-room attempt by the current client. To determine the result of the attempt, use getStatus(), which has the following possible return values:
See also
ROOM_ADDED | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.ROOM_ADDED
Dispatched when the current client gains knowledge of a new room. The current client gains knowledge of a room in the following circumstances.
See also
ROOM_COUNT | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.ROOM_COUNT
Dispatched whenever the RoomManager gains or loses knowledge of a room, as described under RoomManagerEvent.ROOM_ADDED and RoomManagerEvent.ROOM_REMOVED. To determine the new number of rooms, use RoomManagerEvent's getNumRooms() method or RoomManager's getNumRooms() method.
See also
ROOM_REMOVED | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.ROOM_REMOVED
Dispatched when the current client loses knowledge of a new room. The current client loses knowledge of a room in the following circumstances.
See also
STOP_OBSERVING_RESULT | Event |
RoomEvent
net.user1.reactor.RoomEvent.STOP_OBSERVING_RESULT
Dispatched when the result of an earlier stop-observing-room request by the current client is received. To determine the result of the request, use getStatus(), which has the following possible return values:
See also
STOP_WATCHING_FOR_ROOMS_RESULT | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.STOP_WATCHING_FOR_ROOMS_RESULT
Dispatched when the server reports the result of a stop-watching-for-rooms attempt by the current client. To determine the result of the attempt, use getStatus(), which has the following possible return values:
See also
WATCH_FOR_ROOMS_RESULT | Event |
RoomManagerEvent
net.user1.reactor.RoomManagerEvent.WATCH_FOR_ROOMS_RESULT
Dispatched when the server reports the result of a watch-for-rooms attempt by the current client. To determine the result of the attempt, use getStatus(), which has the following possible return values:
See also