Room

Kind of class:public class
Package:it.gotoandplay.smartfoxserver.data
Inherits from:none
Version:1.0.0
Author:The gotoAndPlay() Team
http://www.smartfoxserver.com
http://www.gotoandplay.it
Classpath:it.gotoandplay.smartfoxserver.data.Room
File last modified:Monday, 10 December 2007, 16:16:30
The Room class stores the properties of each server room.
This class is used internally by the SmartFoxClient class; also, Room objects are returned by various methods and events of the SmartFoxServer API.

NOTE: in the provided examples, room always indicates a Room instance.

Summary


Instance methods
  • getUserList : Array
    • Get the list of users currently inside the room.
  • getUser (userId:*) : User
    • Retrieve a user currently in the room.
  • getVariable (varName:String) : *
    • Retrieve a Room Variable.
  • getVariables : Array
    • Retrieve the list of all Room Variables.
  • getName : String
    • Get the name of the room.
  • getId : int
    • Get the id of the room.
  • isTemp : Boolean
    • A boolean flag indicating if the room is dynamic/temporary.
  • isGame : Boolean
    • A boolean flag indicating if the room is a "game room".
  • isPrivate : Boolean
    • A boolean flag indicating if the room is private (password protected).
  • getUserCount : int
    • Retrieve the number of users currently inside the room.
  • getSpectatorCount : int
    • Retrieve the number of spectators currently inside the room.
  • getMaxUsers : int
    • Retrieve the maximum number of users that can join the room.
  • getMaxSpectators : int
    • Retrieve the maximum number of spectators that can join the room.
  • getMyPlayerIndex : int
    • Retrieve the player id for the current user in the room.
  • isLimbo : Boolean
    • A boolean flag indicating if the room is in "limbo mode".

Instance methods

getId

public function getId (
) : int

Get the id of the room.
Returns:
  • The id of the room.
Example:
  • trace("Room id:" + room.getId())
See also:
Version:
  • SmartFoxServer Basic / Pro

getMaxSpectators

public function getMaxSpectators (
) : int

Retrieve the maximum number of spectators that can join the room.
Spectators can exist in game rooms only.
Returns:
  • The maximum number of spectators that can join the room.
Example:
  • if (room.isGame)
        trace("Max spectators allowed to join the room: " + room.getMaxSpectators())
See also:
Version:
  • SmartFoxServer Basic / Pro

getMaxUsers

public function getMaxUsers (
) : int

Retrieve the maximum number of users that can join the room.
Returns:
  • The maximum number of users that can join the room.
Example:
  • trace("Max users allowed to join the room: " + room.getMaxUsers())
See also:
Version:
  • SmartFoxServer Basic / Pro

getMyPlayerIndex

public function getMyPlayerIndex (
) : int

Retrieve the player id for the current user in the room.
This id is 1-based (player 1, player 2, etc.), but if the user is a spectator its value is -1.
Returns:
  • The player id for the current user.
Example:
  • if (room.isGame)
        trace("My player id in this room: " + room.getMyPlayerIndex())
Version:
  • SmartFoxServer Basic / Pro

getName

public function getName (
) : String

Get the name of the room.
Returns:
  • The name of the room.
Example:
  • trace("Room name:" + room.getName())
See also:
Version:
  • SmartFoxServer Basic / Pro

getSpectatorCount

public function getSpectatorCount (
) : int

Retrieve the number of spectators currently inside the room.
Returns:
  • The number of spectators in the room.
Example:
  • var specsNum:int = room.getSpectatorCount()
    trace("There are " + specsNum + " spectators in the room")
See also:
Version:
  • SmartFoxServer Basic / Pro

getUser

public function getUser (
userId:*) : User

Retrieve a user currently in the room.
Parameters:
userId:
the user name (String) or the id (int) of the user to retrieve.
Returns:
Example:
  • var user:User = room.getUser("jack")
See also:
Version:
  • SmartFoxServer Basic / Pro

getUserCount

public function getUserCount (
) : int

Retrieve the number of users currently inside the room.
Returns:
  • The number of users in the room.
Example:
  • var usersNum:int = room.getUserCount()
    trace("There are " + usersNum + " users in the room")
Version:
  • SmartFoxServer Basic / Pro

getUserList

public function getUserList (
) : Array

Get the list of users currently inside the room.
As the returned list is an associative array with user id(s) as keys, in order to iterate it a for-in loop or a for-each loop should be used.
Returns:
  • A list of User objects.
Example:
  • var users:Array = room.getUserList()
    
    for (var u:String in users)
    trace(users[u].getName())
See also:
Version:
  • SmartFoxServer Basic / Pro

getVariable

public function getVariable (
varName:String) : *

Retrieve a Room Variable.
Parameters:
varName:
the name of the variable to retrieve.
Returns:
  • The Room Variable's value.
Example:
  • var location:String = room.getVariable("location") as String
Version:
  • SmartFoxServer Basic / Pro

getVariables

public function getVariables (
) : Array

Retrieve the list of all Room Variables.
Returns:
  • An associative array containing Room Variables' values, where the key is the variable name.
Example:
  • var roomVars:Array = room.getVariables()
    
    for (var v:String in roomVars)
        trace("Name:" + v + " | Value:" + roomVars[v])
Version:
  • SmartFoxServer Basic / Pro

isGame

public function isGame (
) : Boolean

A boolean flag indicating if the room is a "game room".
Returns:
  • true if the room is a "game room".
Example:
  • if (room.isGame)
        trace("This is a game room")
See also:
Version:
  • SmartFoxServer Basic / Pro

isLimbo

public function isLimbo (
) : Boolean

A boolean flag indicating if the room is in "limbo mode".
Returns:
  • true if the room is in "limbo mode".
Example:
  • if (room.isLimbo)
        trace("This is a limbo room")
See also:
Version:
  • SmartFoxServer Basic / Pro

isPrivate

public function isPrivate (
) : Boolean

A boolean flag indicating if the room is private (password protected).
Returns:
  • true if the room is private.
Example:
  • if (room.isPrivate)
        trace("Password required for this room")
Version:
  • SmartFoxServer Basic / Pro

isTemp

public function isTemp (
) : Boolean

A boolean flag indicating if the room is dynamic/temporary.
This is always true for rooms created at runtime on client-side.
Returns:
  • true if the room is a dynamic/temporary room.
Example:
  • if (room.isTemp)
        trace("Room is temporary")
Version:
  • SmartFoxServer Basic / Pro