Class SFS2X.Entities.SFSRoom
The SmartFoxServer Room entity representation on the client.
Constructor Attributes | Constructor Name and Description |
---|---|
SFS2X.Entities.SFSRoom(id, name, groupId)
Creates a new SFSRoom instance.
|
Field Summary
Method Summary
Class Detail
The Room is the basic structure used to group users connected to SmartFoxServer 2X. The client API is not aware of all the Rooms existing 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.
NOTE: developers never istantiate a SFSRoom manually: this is done by the SmartFoxServer 2X API internally. Creating an instance and passing it to the API can disrupt its functioning. You should use the CreateRoomRequest request instead.
- Parameters:
- {Number} id
- The Room id.
- {String} name
- The Room name.
- {String} groupId Optional, Default: "default"
- The id of the Group to which the Room belongs.
- See also:
- SFS2X.SmartFox#roomManager
- SFS2X.Requests.System.CreateRoomRequest
- SFS2X.Requests.System.JoinRoomRequest
- SFS2X.Requests.System.SubscribeRoomGroupRequest
- SFS2X.Requests.System.UnsubscribeRoomGroupRequest
- SFS2X.Requests.System.ChangeRoomNameRequest
- SFS2X.Requests.System.ChangeRoomPasswordStateRequest
- SFS2X.Requests.System.ChangeRoomCapacityRequest
Field Detail
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.
NOTE: setting the groupId property manually has no effect on the server and can disrupt the API functioning. This must be set when creating the Room.
- Default Value:
- "default"
- See also:
- SFS2X.Requests.System.SubscribeRoomGroupRequest
- SFS2X.Requests.System.UnsubscribeRoomGroupRequest
NOTE: the id is unique and it is generated by the server when the Room is created. Setting it manually has no effect on the server and can disrupt the API functioning.
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.
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.
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.
- See also:
- SFS2X.Requests.System.JoinRoomRequest
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.
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.
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.
NOTE: setting the name property manually has no effect on the server and can disrupt the API functioning. Use the ChangeRoomNameRequest request instead.
Method Detail
-
{Boolean} containsUser(user)Indicates whether the specified user is currently inside this Room or not.
- Parameters:
- {SFSUser} user
- The SFSUser object representing the user whose presence in this Room must be checked.
- Returns:
- {Boolean}
true
if the user is inside this Room;false
otherwise.
-
{Boolean} containsVariable(varName)Indicates whether this Room has the specified Room Variable set or not.
- Parameters:
- {String} varName
- The name of the Room Variable whose existance in this Room must be checked.
- Returns:
- {Boolean}
true
if a Room Variable with the passed name exists in this Room.
-
{Number} getCapacity()Returns the maximum amount of users, including spectators, that can be contained in this Room.
- Returns:
- {Number} Maximum number of users that can enter the Room.
-
{Array} getPlayerList()Retrieves the list of SFSUser objects representing the players currently inside this Room (Game Rooms only).
- Returns:
- {Array} The list of SFSUser objects representing the users who joined the Room as players.
-
{RoomManager} getRoomManager()Retrieves a reference to the Room Manager which manages this Room.
- Returns:
- {RoomManager} The Room Manager to which this Room is associated.
-
{Number} getSpectatorCount()Returns the current number of spectators in this Room (Game Rooms only).
- Returns:
- {Number} Current number of spectators in the Room.
-
{Array} getSpectatorList()Retrieves the list of SFSUser objects representing the spectators currently inside this Room (Game Rooms only).
- Returns:
- {Array} The list of SFSUser objects representing the users who joined the Room as spectators.
-
{SFSUser} getUserById(id)Retrieves a SFSUser object from its id property.
- Parameters:
- {Number} id
- The id of the user to be found.
- Returns:
- {SFSUser} An object representing the user, or
null
if no user with the passed id exists in this Room.
-
{SFSUser} getUserByName(name)Retrieves a SFSUser object from its name property.
- Parameters:
- {String} name
- The name of the user to be found.
- Returns:
- {SFSUser} An object representing the user, or
null
if no user with the passed name exists in this Room.
-
{Number} getUserCount()Returns the current number of users in this Room. In case of Game Rooms, this is the number of players.
- Returns:
- {Number} Current number of users in the Room.
-
{Array} getUserList()Retrieves the list of SFSUser objects representing all the users currently inside this Room.
- Returns:
- {Array} The list of SFSUser objects representing the users who joined the Room.
-
{SFSRoomVariable} getVariable(varName)Retrieves a Room Variable from its name.
- Parameters:
- {String} varName
- The name of the Room Variable to be retrieved.
- Returns:
- {SFSRoomVariable} The object representing the Room Variable, or
null
if no Room Variable with the passed name exists in this Room. - See also:
- SFS2X.Entities.Variables.SFSRoomVariable
- SFS2X.Requests.System.SetRoomVariablesRequest
-
{Array} getVariables()Retrieves all the Room Variables of this Room.
- Returns:
- {Array} The list of SFSRoomVariable objects associated with this Room.
- See also:
- SFS2X.Entities.Variables.SFSRoomVariable
-
{String} toString()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.