Class SFS2X.Managers.RoomManager

The manager of the client-side Rooms list.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new RoomManager instance.

Method Summary

Class Detail

SFS2X.Managers.RoomManager(sfs)
Creates a new RoomManager instance.

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.

NOTE: developers never istantiate a RoomManager manually: this is done by the SmartFoxServer 2X API internally. A reference to the existing instance can be retrieved using the SmartFox.roomManager property.

Parameters:
{SmartFox} sfs
An instance of the SmartFoxServer 2X client API main SmartFox class.
See also:
SFS2X.SmartFox#roomManager

Method Detail

  • {Boolean} containsGroup(groupId)
    Indicates whether the specified Group has been subscribed by the client or not.
    Parameters:
    {String} groupId
    The name of the Group.
    Returns:
    {Boolean} true if the client subscribed the passed Group.
  • {Boolean} containsRoom(idOrName)
    Indicates whether a Room exists in the Rooms list or not.
    Parameters:
    {*} idOrName
    The id or name of the SFSRoom object whose presence in the Rooms list is to be tested.
    Returns:
    {Boolean} true if the passed Room exists in the Rooms list.
    See also:
    SFS2X.Entities.SFSRoom#id
    SFS2X.Entities.SFSRoom#name
  • {Boolean} containsRoomInGroup(idOrName, groupId)
    Indicates whether the Rooms list contains a Room belonging to the specified Group or not.
    Parameters:
    {*} idOrName
    The id or name of the SFSRoom object whose presence in the Rooms list is to be tested.
    {String} groupId
    The name of the Group to which the specified Room must belong.
    Returns:
    {Boolean} true if the Rooms list contains the passed Room and it belongs to the specified Group.
    See also:
    SFS2X.Entities.SFSRoom#id
    SFS2X.Entities.SFSRoom#name
    SFS2X.Entities.SFSRoom#groupId
  • {Array} getJoinedRooms()
    Returns a list of Rooms currently joined by the client.
    Returns:
    {Array} The list of SFSRoom objects representing the Rooms currently joined by the client.
    See also:
    SFS2X.Entities.SFSRoom
    SFS2X.Requests.System.JoinRoomRequest
  • {SFSRoom} getRoomById(id)
    Retrieves a SFSRoom object from its id.

    The following 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);
    Parameters:
    {Number} id
    The id of the Room.
    Returns:
    {SFSRoom} The object representing the requested Room; null if no SFSRoom object with the passed id exists in the Rooms list.
  • {SFSRoom} getRoomByName(name)
    Retrieves a SFSRoom object from its name.

    The following example retrieves a SFSRoom object and traces its id:

    var roomName = "The Lobby";
    var room = sfs.getRoomByName(roomName);
    console.log("The ID of Room '" + roomName + "' is " + room.id);
    Parameters:
    {String} name
    The name of the Room.
    Returns:
    {SFSRoom} The object representing the requested Room; null if no SFSRoom object with the passed name exists in the Rooms list.
  • {Number} getRoomCount()
    Returns the current number of Rooms in the Rooms list.
    Returns:
    {Number} The number of Rooms in the Rooms list.
  • {Array} getRoomGroups()
    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.

    Returns:
    {Array} A list of Group names.
    See also:
    SFS2X.Entities.SFSRoom#groupId
    SFS2X.Requests.System.SubscribeRoomGroupRequest
    SFS2X.Requests.System.UnsubscribeRoomGroupRequest
  • {Array} getRoomList()
    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.

    Returns:
    {Array} The list of the available SFSRoom objects.
    See also:
    SFS2X.Entities.SFSRoom
    SFS2X.Requests.System.JoinRoomRequest
    SFS2X.Requests.System.SubscribeRoomGroupRequest
    SFS2X.Requests.System.UnsubscribeRoomGroupRequest
  • {Array} getRoomListFromGroup(groupId)
    Retrieves the list of Rooms which are part of the specified Room Group.
    Parameters:
    {String} groupId
    The name of the Group.
    Returns:
    {Array} The list of SFSRoom objects belonging to the passed Group.
    See also:
    SFS2X.Entities.SFSRoom
  • {Array} getUserRooms(user)
    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.
    Parameters:
    {SFSUser} user
    A SFSUser object representing the user to look for in the current Rooms list.
    Returns:
    {Array} The list of Rooms joined by the passed user.