SFSRoom

Represents a SmartFoxServer Room entity on the client.


The SmartFoxServer client is 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 the client 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 updated continuously by the server.

Members

DEFAUL_GROUP_ID

Identifier (name) of the Group to which Rooms are assigned by default.

(readonly) capacity :number

Maximum amount of Users, including Spectators, allowed to join the Room.
Type:
  • number

(readonly) groupId :string

Identifier (name) of the Room Group to which the Room belongs.

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

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

Type:
  • string
Default Value
  • default

(readonly) id :number

Identifier of the Room.

The id is unique and it is generated by the server when the Room is created.

Type:
  • number

(readonly) isAudioStreamingAllowed :boolean

Indicates whether audio streaming is allowed in the Room.
Type:
  • boolean

(readonly) isGame :boolean

Indicates whether the Room is a Game Room.
Type:
  • boolean

(readonly) isHidden :boolean

Indicates whether the Room is hidden.

This is a utility flag that can be used by developers to hide certain Rooms from the interface of their application.

Type:
  • boolean

(readonly) isJoined :boolean

Indicates whether the client joined the Room.
Type:
  • boolean

(readonly) isPasswordProtected :boolean

Indicates whether the Room requires a password to be joined.

This flag depends on the Room password set when the Room is created or by means of the ChangeRoomPasswordStateRequest.

Type:
  • boolean

(readonly) maxSpectators :number

Maximum number of Spectators allowed to join the Room (Game Rooms only).
Type:
  • number

(readonly) maxUsers :number

Maximum number of Users allowed to join the Room.

In case of Game Rooms, this is also the maximum number of Players.

Type:
  • number

(readonly) name :string

Name of the Room.

Two Rooms in the same Zone cannot have the same name.

Type:
  • string

(readonly) playerList :Array.<SFSUser>

List of SFSUser objects representing the Players currently inside the Room (Game Rooms only).
Type:

(readonly) roomManager :SFSRoomManager

Reference to the Room Manager which manages the Room.

(readonly) spectatorCount :number

Current number of Spectators in the Room (Game Rooms only).
Type:
  • number

(readonly) spectatorList :Array.<SFSUser>

List of SFSUser objects representing the Spectators currently inside the Room (Game Rooms only).
Type:

(readonly) userCount :number

Current number of Users in the Room.

In case of Game Rooms, this is also the number of Players.

Type:
  • number

(readonly) userList :Array.<SFSUser>

List of SFSUser objects representing all the Users currently inside the Room.
Type:

Methods

containsUser(user) → {boolean}

Indicates whether the specified User is currently inside the Room.
Parameters:
NameTypeDescription
userSFSUserThe object representing the User whose presence in the Room must be checked.
Returns:
true if the User is inside the Room.
Type: 
boolean

containsVariable(varName) → {boolean}

Indicates whether the Room has the specified Room Variable set.
Parameters:
NameTypeDescription
varNamestringThe name of the Room Variable whose existance must be checked.
Returns:
true if a Room Variable with the passed name is found.
Type: 
boolean

getUserById(id) → {SFSUser}

Retrieves a SFSUser object by its id.
Parameters:
NameTypeDescription
idnumberThe id of the User to be found.
Returns:
The object representing the User, or null if no User with the passed id can be found in the Room.
Type: 
SFSUser

getUserByName(name) → {SFSUser}

Retrieves a SFSUser object by its name.
Parameters:
NameTypeDescription
namestringThe name of the User to be found.
Returns:
The object representing the User, or null if no User with the passed name can be found in the Room.
Type: 
SFSUser

getVariable(varName) → {SFSRoomVariable}

Retrieves a Room Variable by its name.
Parameters:
NameTypeDescription
varNamestringThe name of the Room Variable to be retrieved.
Returns:
The object representing the Room Variable, or null if no Room Variable with the passed name belongs to the Room.
Type: 
SFSRoomVariable

getVariables() → {Array.<SFSRoomVariable>}

Returns all Room Variables belonging to the Room.
Returns:
A list of objects representing the Room Variables.
Type: 
Array.<SFSRoomVariable>

toString() → {string}

Returns a string containing the Room id, name and id of the Group to which it belongs.
Returns:
The string representation of the SFSRoom object.
Type: 
string