|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectit.gotoandplay.smartfoxclient.data.Room
public class Room
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.
| 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 |
|---|
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 |
|---|
public void addUser(User u,
int id)
public void removeUser(int id)
public java.util.Map<java.lang.Integer,User> getUserList()
User objects.
Example
Map<Integer, User> users = room.getUserList();
for(int userId : users.keySet())
{
System.out.println(users.get(userId));
}
getUser(java.lang.String),
Userpublic void setUserList(java.util.Map<java.lang.Integer,User> userList)
public User getUser(java.lang.String userName)
userName - the user name of the user to retrieve.
User object.
Example
User user = room.getUser("jack");
getUserList(),
Userpublic User getUser(int userId)
userId - the user id of the user to retrieve.
User object.
Example
User user = room.getUser("jack");
getUserList(),
Userpublic void clearUserList()
public SFSVariable getVariable(java.lang.String varName)
varName - the name of the variable to retrieve.
Example
String location = room.getVariable("location").getValue();
getVariables(),
SFSVariable,
SmartFoxClient.setRoomVariables(java.util.Map) public java.util.Map<java.lang.String,SFSVariable> getVariables()
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));
}
getVariable(java.lang.String),
SmartFoxClient.setRoomVariables(java.util.Map) public void setVariables(java.util.Map<java.lang.String,SFSVariable> vars)
public void clearVariables()
public java.lang.String getName()
Example
System.out.println("Room name:" + room.getName());
getId()public int getId()
Example
System.out.println("Room id:" + room.getId());
getName()public boolean isTemp()
true if the room is a dynamic/temporary room.
Example
if (room.isTemp())
{
System.out.println("Room is temporary");
}
public boolean isGame()
true if the room is a "game room".
Example
if (room.isGame())
{
System.out.println("This is a game room");
}
isLimbo()public boolean isPrivate()
true if the room is private.
Example
if (room.isPrivate())
{
System.out.println("Password required for this room");
}
public int getUserCount()
Example
int usersNum = room.getUserCount();
System.out.println("There are " + usersNum + " users in the room");
getSpectatorCount()public int getSpectatorCount()
Example
int specsNum = room.getSpectatorCount();
System.out.println("There are " + specsNum + " spectators in the room");
getUserCount()public int getMaxUsers()
Example
System.out.println("Max users allowed to join the room: " + room.getMaxUsers());
getMaxSpectators()public int getMaxSpectators()
Example
if (room.isGame())
{
System.out.println("Max spectators allowed to join the room: " + room.getMaxSpectators());
}
getMaxUsers()public void setMyPlayerIndex(int id)
public int getMyPlayerIndex()
Example
if (room.isGame())
{
System.out.println("My player id in this room: " + room.getMyPlayerIndex());
}
public void setIsLimbo(boolean b)
public boolean isLimbo()
true if the room is in "limbo mode".
Example
if (room.isLimbo())
{
System.out.println("This is a limbo room");
}
isGame()public void setUserCount(int n)
public void setSpectatorCount(int n)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||