new SFSRoomManager()

Developers never istantiate the SFSRoomManager class: this is done internally by the SmartFoxServer 2X API; get a reference to it using the SmartFox.roomManager property.

This class keeps track of all the Rooms available in the client-side Rooms list and of subscriptions to multiple Room Groups. It also provides various utility methods to look for Rooms by name and id, retrieve Rooms belonging to a specific Group, etc.

See also
SmartFox#roomManager

Methods

containsGroup(groupId) → boolean

Indicates whether the specified Group has been subscribed by the client or not.

Parameter

Name Type Optional Description

groupId

string

 

The name of the Group.

Returns

boolean true if the client subscribed the passed Group.

containsRoom(idOrName) → boolean

Indicates whether a Room exists in the Rooms list or not.

Parameter

Name Type Optional Description

idOrName

(number or string)

 

The id or name of the SFSRoom object whose presence in the Rooms list is to be tested.

See also
SFSRoom#id
SFSRoom#name
Returns

boolean true if the passed Room exists in the Rooms list.

containsRoomInGroup(idOrName, groupId) → boolean

Indicates whether the Rooms list contains a Room belonging to the specified Group or not.

Parameters

Name Type Optional Description

idOrName

(number or string)

 

The id or name of the SFSRoom object whose presence in the Rooms list is to be tested.

groupId

string

 

The name of the Group to which the specified Room must belong.

See also
SFSRoom#id
SFSRoom#name
SFSRoom#groupId
Returns

boolean true if the Rooms list contains the passed Room and it belongs to the specified Group.

getJoinedRooms() → Array of SFSRoom

Returns a list of Rooms currently joined by the client.

See also
JoinRoomRequest
Returns

Array of SFSRoom The list of SFSRoom objects representing the Rooms currently joined by the client.

getRoomById(id) → SFSRoom

Retrieves a SFSRoom object from its id property.

Example

This example retrieves a SFSRoom object and traces its name.

var roomId = 3;
var room = sfs.getRoomById(roomId);
console.log("The name of Room " + roomId + " is " + room.name);

Parameter

Name Type Optional Description

id

number

 

The id of the Room to be retrieved.

Returns

SFSRoom The object representing the requested Room; undefined if no SFSRoom object with the passed id exists in the Rooms list.

getRoomByName(name) → SFSRoom

Retrieves a SFSRoom object from its name property.

Example

This example retrieves a <em>SFSRoom</em> object and traces its id.

var roomName = "The Lobby";
var room = sfs.getRoomByName(roomName);
console.log("The ID of Room '" + roomName + "' is " + room.id);

Parameter

Name Type Optional Description

name

string

 

The name of the Room to be retrieved.

Returns

SFSRoom The object representing the requested Room; undefined if no SFSRoom object with the passed name exists in the Rooms list.

getRoomCount() → number

Returns the current number of Rooms in the Rooms list.

Returns

number The number of Rooms in the Rooms list.

getRoomGroups() → Array of string

Returns the names of Groups currently subscribed by the client.

NOTE: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.

See also
SFSRoom#groupId
SubscribeRoomGroupRequest
UnsubscribeRoomGroupRequest
Returns

Array of string A list of Group names.

getRoomList() → Array of SFSRoom

Returns a list of Rooms currently "known" by the client.

The list contains all the Rooms that are currently joined and all the Rooms belonging to the Room Groups that have been subscribed.

NOTE: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.

See also
JoinRoomRequest
SubscribeRoomGroupRequest
UnsubscribeRoomGroupRequest
Returns

Array of SFSRoom The list of the available SFSRoom objects.

getRoomListFromGroup(groupId) → Array of SFSRoom

Retrieves the list of Rooms which are part of the specified Room Group.

Parameter

Name Type Optional Description

groupId

string

 

The name of the Group.

See also
SubscribeRoomGroupRequest
Returns

Array of SFSRoom The list of SFSRoom objects belonging to the passed Group.

getUserRooms(user) → Array of SFSRoom

Retrieves a list of Rooms joined by the specified user.

The list contains only those Rooms "known" by the Room Manager; the user might have joined others the client is not aware of.

Parameter

Name Type Optional Description

user

SFSUser

 

A SFSUser object representing the user to look for in the current Rooms list.

Returns

Array of SFSRoom The list of Rooms joined by the passed user.