Packagecom.smartfoxserver.v2.entities
Classpublic class SFSRoom
InheritanceSFSRoom Inheritance Object
Implements Room
Subclasses MMORoom

The SFSRoom object represents a SmartFoxServer Room entity on the client.

The SmartFoxServer 2X client API are not aware of all the Rooms which exist on the server side, but only of those that are joined by the user and those in the Room Groups that have been subscribed. Subscribing to one or more Groups allows the client to listen to Room events in specific "areas" of the Zone, without having to retrieve and keep synchronized the details of all available Rooms, thus reducing the traffic between the client and the server considerably.

The list of available Rooms is created after a successful login and it is kept updated continuously by the server.

See also

SmartFox.roomManager
CreateRoomRequest
JoinRoomRequest
SubscribeRoomGroupRequest
UnsubscribeRoomGroupRequest
ChangeRoomNameRequest
ChangeRoomPasswordStateRequest
ChangeRoomCapacityRequest


Public Properties
 PropertyDefined By
  capacity : int
[read-only] Returns the maximum amount of users, including spectators, that can be contained in this Room.
SFSRoom
  groupId : String
[read-only] Returns the Room Group name.
SFSRoom
  id : int
[read-only] Indicates the id of this Room.
SFSRoom
  isGame : Boolean
Indicates whether this is a Game Room or not.
SFSRoom
  isHidden : Boolean
Indicates whether this Room is hidden or not.
SFSRoom
  isJoined : Boolean
Indicates whether the client joined this Room or not.
SFSRoom
  isPasswordProtected : Boolean
Indicates whether this Room requires a password to be joined or not.
SFSRoom
  maxSpectators : int
Returns the maximum number of spectators allowed in this Room (Game Rooms only).
SFSRoom
  maxUsers : int
Returns the maximum number of users allowed in this Room.
SFSRoom
  name : String
Indicates the name of this Room.
SFSRoom
  playerList : Array
[read-only] Returns a list of User objects representing the players currently inside this Room (Game Rooms only).
SFSRoom
  properties : Object
Defines a generic utility object that can be used to store custom Room data.
SFSRoom
  roomManager : IRoomManager
Returns a reference to the Room Manager which manages this Room.
SFSRoom
  spectatorCount : int
Returns the current number of spectators in this Room (Game Rooms only).
SFSRoom
  spectatorList : Array
[read-only] Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only).
SFSRoom
  userCount : int
Returns the current number of users in this Room.
SFSRoom
  userList : Array
[read-only] Returns a list of User objects representing all the users currently inside this Room.
SFSRoom
Public Methods
 MethodDefined By
  
SFSRoom(id:int, name:String, groupId:String = default)
Creates a new SFSRoom instance.
SFSRoom
  
containsUser(user:User):Boolean
Indicates whether the specified user is currently inside this Room or not.
SFSRoom
  
containsVariable(name:String):Boolean
Indicates whether this Room has the specified Room Variable set or not.
SFSRoom
  
Retrieves a User object from its id property.
SFSRoom
  
getUserByName(name:String):User
Retrieves a User object from its name property.
SFSRoom
  
Retrieves a Room Variable from its name.
SFSRoom
  
getVariables():Array
Retrieves all the Room Variables of this Room.
SFSRoom
  
toString():String
Returns a string that contains the Room id, name and id of the Group to which it belongs.
SFSRoom
Property Detail
capacityproperty
capacity:int  [read-only]

Returns the maximum amount of users, including spectators, that can be contained in this Room.


Implementation
    public function get capacity():int
groupIdproperty 
groupId:String  [read-only]

Returns the Room Group name. Each Group is identified by a unique string (its name or id) and it represents a different "container" for Rooms.

Room Groups enable developers to organize Rooms under different types or categories and let clients select only those Groups they are interested in, in order to receive their events only. This is done via the SubscribeRoomGroupRequest and UnsubscribeRoomGroupRequest requests.


Implementation
    public function get groupId():String
idproperty 
id:int  [read-only]

Indicates the id of this Room. It is unique and it is generated by the server when the Room is created.


Implementation
    public function get id():int
isGameproperty 
isGame:Boolean

Indicates whether this is a Game Room or not.

NOTE: setting the isGame property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.


Implementation
    public function get isGame():Boolean
    public function set isGame(value:Boolean):void
isHiddenproperty 
isHidden:Boolean

Indicates whether this Room is hidden or not. This is a utility flag that can be used by developers to hide certain Rooms from the interface of their application.

NOTE: setting the isHidden property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.


Implementation
    public function get isHidden():Boolean
    public function set isHidden(value:Boolean):void
isJoinedproperty 
isJoined:Boolean

Indicates whether the client joined this Room or not.

NOTE: setting the isJoined property manually has no effect on the server and can disrupt the API functioning. Use the JoinRoomRequest request to join a new Room instead.


Implementation
    public function get isJoined():Boolean
    public function set isJoined(value:Boolean):void
isPasswordProtectedproperty 
isPasswordProtected:Boolean

Indicates whether this Room requires a password to be joined or not.

NOTE: setting the isPasswordProtected property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room's password set when the Room is created or by means of the ChangeRoomPasswordStateRequest request.


Implementation
    public function get isPasswordProtected():Boolean
    public function set isPasswordProtected(value:Boolean):void
maxSpectatorsproperty 
maxSpectators:int

Returns the maximum number of spectators allowed in this Room (Game Rooms only).

NOTE: setting the maxSpectators property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Game Room.


Implementation
    public function get maxSpectators():int
    public function set maxSpectators(value:int):void
maxUsersproperty 
maxUsers:int

Returns the maximum number of users allowed in this Room. In case of Game Rooms, this is the maximum number of players.

NOTE: setting the maxUsers property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.


Implementation
    public function get maxUsers():int
    public function set maxUsers(value:int):void
nameproperty 
name:String

Indicates the name of this Room. Two Rooms in the same Zone can't have the same name.

NOTE: setting the name property manually has no effect on the server and can disrupt the API functioning. Use the ChangeRoomNameRequest request instead.


Implementation
    public function get name():String
    public function set name(value:String):void
playerListproperty 
playerList:Array  [read-only]

Returns a list of User objects representing the players currently inside this Room (Game Rooms only).


Implementation
    public function get playerList():Array
propertiesproperty 
properties:Object

Defines a generic utility object that can be used to store custom Room data. The values added to this object are for client-side use only and are never transmitted to the server or to the other clients.


Implementation
    public function get properties():Object
    public function set properties(value:Object):void
roomManagerproperty 
roomManager:IRoomManager

Returns a reference to the Room Manager which manages this Room.

NOTE: setting the roomManager property manually has no effect on the server and can disrupt the API functioning.


Implementation
    public function get roomManager():IRoomManager
    public function set roomManager(value:IRoomManager):void
spectatorCountproperty 
spectatorCount:int

Returns the current number of spectators in this Room (Game Rooms only).

NOTE: setting the spectatorCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.


Implementation
    public function get spectatorCount():int
    public function set spectatorCount(value:int):void
spectatorListproperty 
spectatorList:Array  [read-only]

Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only).


Implementation
    public function get spectatorList():Array
userCountproperty 
userCount:int

Returns the current number of users in this Room. In case of Game Rooms, this is the number of players.

NOTE: setting the userCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.


Implementation
    public function get userCount():int
    public function set userCount(value:int):void
userListproperty 
userList:Array  [read-only]

Returns a list of User objects representing all the users currently inside this Room.


Implementation
    public function get userList():Array
Constructor Detail
SFSRoom()Constructor
public function SFSRoom(id:int, name:String, groupId:String = default)

Creates a new SFSRoom instance.

NOTE: developers never istantiate a SFSRoom manually: this is done by the SmartFoxServer 2X API internally.

Parameters
id:int — The Room id.
 
name:String — The Room name.
 
groupId:String (default = default) — The id of the Group to which the Room belongs.
Method Detail
containsUser()method
public function containsUser(user:User):Boolean

Indicates whether the specified user is currently inside this Room or not.

Parameters

user:User — The User object representing the user whose presence in this Room must be checked.

Returns
Booleantrue if the user is inside this Room; false otherwise.
containsVariable()method 
public function containsVariable(name:String):Boolean

Indicates whether this Room has the specified Room Variable set or not.

Parameters

name:String — The name of the Room Variable whose existance in this Room must be checked.

Returns
Booleantrue if a Room Variable with the passed name exists in this Room.
getUserById()method 
public function getUserById(id:int):User

Retrieves a User object from its id property.

Parameters

id:int — The id of the user to be retrieved.

Returns
User — The User object representing the user, or null if no user with the passed id exists in this Room.
getUserByName()method 
public function getUserByName(name:String):User

Retrieves a User object from its name property.

Parameters

name:String — The name of the user to be found.

Returns
User — The User object representing the user, or null if no user with the passed name exists in this Room.
getVariable()method 
public function getVariable(name:String):RoomVariable

Retrieves a Room Variable from its name.

Parameters

name:String — The name of the Room Variable to be retrieved.

Returns
RoomVariable — The RoomVariable object representing the Room Variable, or null if no Room Variable with the passed name exists in this Room.
getVariables()method 
public function getVariables():Array

Retrieves all the Room Variables of this Room.

Returns
Array — The list of RoomVariable objects associated with this Room.
merge()method 
kernel function merge(anotherRoom:Room):void

Parameters

anotherRoom:Room

toString()method 
public function toString():String

Returns a string that contains the Room id, name and id of the Group to which it belongs.

Returns
String — The string representation of the SFSRoom object.