Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## it.gotoandplay.smartfoxclient.data
Class Room

    java.lang.Object
      it.gotoandplay.smartfoxclient.data.Room

    public class Room

extends java.lang.Object

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.

Version:
  1.0.0
Author:
  The gotoAndPlay() Team
  http://www.smartfoxserver.com
  http://www.gotoandplay.it

Constructor Summary
`Room(int id, java.lang.String name, int maxUsers, int maxSpectators, boolean isTemp, boolean isGame, boolean isPrivate, boolean isLimbo, int userCount, int specCount)`

Method Summary
`void` | `addUser(User u, int id)`
`void` | `clearUserList()`
`void` | `clearVariables()`
`int` | `getId()` Get the id of the room.
`int` | `getMaxSpectators()` Retrieve the maximum number of spectators that can join the room.
`int` | `getMaxUsers()` Retrieve the maximum number of users that can join the room.
`int` | `getMyPlayerIndex()` Retrieve the player id for the current user in the room.
`java.lang.String` | `getName()` Get the name of the room.
`int` | `getSpectatorCount()` Retrieve the number of spectators currently inside the room.
`User` | `getUser(int userId)` Retrieve a user currently in the room.
`User` | `getUser(java.lang.String userName)` Retrieve a user currently in the room.
`int` | `getUserCount()` Retrieve the number of users currently inside the room.
`java.util.Map<java.lang.Integer,User>` | `getUserList()` Get the list of users currently inside the room.
`SFSVariable` | `getVariable(java.lang.String varName)` Retrieve a Room Variable.
`java.util.Map<java.lang.String,SFSVariable>` | `getVariables()` Retrieve all Room Variables.
`boolean` | `isGame()` A boolean flag indicating if the room is a "game room".
`boolean` | `isLimbo()` A boolean flag indicating if the room is in "limbo mode".
`boolean` | `isPrivate()` A boolean flag indicating if the room is private (password protected).
`boolean` | `isTemp()` A boolean flag indicating if the room is dynamic/temporary.
`void` | `removeUser(int id)`
`void` | `setIsLimbo(boolean b)`
`void` | `setMyPlayerIndex(int id)`
`void` | `setSpectatorCount(int n)`
`void` | `setUserCount(int n)`
`void` | `setUserList(java.util.Map<java.lang.Integer,User> userList)`
`void` | `setVariables(java.util.Map<java.lang.String,SFSVariable> vars)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Room

    public Room(int id,
                java.lang.String name,
                int maxUsers,
                int maxSpectators,
                boolean isTemp,
                boolean isGame,
                boolean isPrivate,
                boolean isLimbo,
                int userCount,
                int specCount)

Method Detail

### addUser

    public void addUser(User u,
                        int id)

### removeUser

    public void removeUser(int id)

### getUserList

    public java.util.Map<java.lang.Integer,User> getUserList()

  Get the list of users currently inside the room. The returned list is an java.util.Map with user id(s) as keys.

  Returns:
    A Map of `User` objects.

    Example

         Map<Integer, User> users = room.getUserList();

         for(int userId : users.keySet())
         {
             System.out.println(users.get(userId));
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getUser(java.lang.String)`, `User`

### setUserList

    public void setUserList(java.util.Map<java.lang.Integer,User> userList)

### getUser

    public User getUser(java.lang.String userName)

  Retrieve a user currently in the room.

  Parameters:
    `userName` - the user name of the user to retrieve.
  Returns:
    A `User` object.

    Example

         User user = room.getUser("jack");

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getUserList()`, `User`

### getUser

    public User getUser(int userId)

  Retrieve a user currently in the room.

  Parameters:
    `userId` - the user id of the user to retrieve.
  Returns:
    A `User` object.

    Example

         User user = room.getUser("jack");

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getUserList()`, `User`

### clearUserList

    public void clearUserList()

### getVariable

    public SFSVariable getVariable(java.lang.String varName)

  Retrieve a Room Variable.

  Parameters:
    `varName` - the name of the variable to retrieve.
  Returns:
    The Room Variable.

    Example

         String location = room.getVariable("location").getValue();

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getVariables()`, `SFSVariable`, `SmartFoxClient.setRoomVariables(java.util.Map)`

### getVariables

    public java.util.Map<java.lang.String,SFSVariable> getVariables()

  Retrieve all Room Variables.

  Returns:
    A `Map` containing Room Variables, where the key is the variable name.

    Example

         Map<String, RoomVariable> roomVars = room.getVariables();

         for(String varName : roomVars.keySet())
         {
             System.out.println("Name: " + varName + " | Value: " + roomVars.get(varName));
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getVariable(java.lang.String)`, `SmartFoxClient.setRoomVariables(java.util.Map)`

### setVariables

    public void setVariables(java.util.Map<java.lang.String,SFSVariable> vars)

### clearVariables

    public void clearVariables()

### getName

    public java.lang.String getName()

  Get the name of the room.

  Returns:
    The name of the room.

    Example

         System.out.println("Room name:" + room.getName());

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getId()`

### getId

    public int getId()

  Get the id of the room.

  Returns:
    The id of the room.

    Example

         System.out.println("Room id:" + room.getId());

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getName()`

### isTemp

    public boolean isTemp()

  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())
         {
             System.out.println("Room is temporary");
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x

### isGame

    public boolean isGame()

  A boolean flag indicating if the room is a "game room".

  Returns:
    `true` if the room is a "game room".

    Example

         if (room.isGame())
         {
             System.out.println("This is a game room");
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `isLimbo()`

### isPrivate

    public boolean isPrivate()

  A boolean flag indicating if the room is private (password protected).

  Returns:
    `true` if the room is private.

    Example

         if (room.isPrivate())
         {
             System.out.println("Password required for this room");
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x

### getUserCount

    public int getUserCount()

  Retrieve the number of users currently inside the room.

  Returns:
    The number of users in the room.

    Example

         int usersNum = room.getUserCount();
         System.out.println("There are " + usersNum + " users in the room");

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getSpectatorCount()`

### getSpectatorCount

    public int getSpectatorCount()

  Retrieve the number of spectators currently inside the room.

  Returns:
    The number of spectators in the room.

    Example

         int specsNum = room.getSpectatorCount();
         System.out.println("There are " + specsNum + " spectators in the room");

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getUserCount()`

### getMaxUsers

    public int getMaxUsers()

  Retrieve the maximum number of users that can join the room.

  Returns:
    The maximum number of users that can join the room.

    Example

         System.out.println("Max users allowed to join the room: " + room.getMaxUsers());

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getMaxSpectators()`

### getMaxSpectators

    public int getMaxSpectators()

  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())
         {
             System.out.println("Max spectators allowed to join the room: " + room.getMaxSpectators());
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `getMaxUsers()`

### setMyPlayerIndex

    public void setMyPlayerIndex(int id)

### getMyPlayerIndex

    public int getMyPlayerIndex()

  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())
         {
             System.out.println("My player id in this room: " + room.getMyPlayerIndex());
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x

### setIsLimbo

    public void setIsLimbo(boolean b)

### isLimbo

    public boolean isLimbo()

  A boolean flag indicating if the room is in "limbo mode".

  Returns:
    `true` if the room is in "limbo mode".

    Example

         if (room.isLimbo())
         {
             System.out.println("This is a limbo room");
         }

  Since:
    SmartFoxServer Basic / Pro v1.x.x
  See Also:
    `isGame()`

### setUserCount

    public void setUserCount(int n)

### setSpectatorCount

    public void setSpectatorCount(int n)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD