|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectit.gotoandplay.smartfoxclient.data.User
public class User
The User class stores the properties of each user.
This class is used internally by the SmartFoxClient class;
also, User objects are returned by various methods and events of the SmartFoxServer API.
NOTE: in the provided examples, user always indicates a User instance.
| Constructor Summary | |
|---|---|
User(int id,
java.lang.String name)
|
|
| Method Summary | |
|---|---|
void |
clearVariables()
|
int |
getId()
Get the id of the user. |
java.lang.String |
getName()
Get the name of the user. |
int |
getPlayerId()
Retrieve the player id of the user. |
SFSVariable |
getVariable(java.lang.String varName)
Retrieve a User Variable. |
java.util.Map<java.lang.String,SFSVariable> |
getVariables()
Retrieve all User Variables. |
boolean |
isModerator()
A boolean flag indicating if the user is a Moderator in the current zone. |
boolean |
isSpectator()
A boolean flag indicating if the user is a spectator in the current room. |
void |
setIsSpectator(boolean b)
|
void |
setModerator(boolean b)
|
void |
setPlayerId(int pid)
|
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 User(int id,
java.lang.String name)
| Method Detail |
|---|
public int getId()
Example
System.out.println("User id:" + user.getId());
getName()public java.lang.String getName()
Example
System.out.println("User name:" + user.getName());
getId()public SFSVariable getVariable(java.lang.String varName)
varName - the name of the variable to retrieve.
Example
int age = Integer.parseInt(room.getVariable("age").getValue());
getVariables(),
SFSVariable,
SmartFoxClient.setUserVariables(java.util.Map) public java.util.Map<java.lang.String,SFSVariable> getVariables()
Map containing User Variables, where the key is the variable name.
Example
Map<String, SFSVariable> userVars = user.getVariables();
for(String varName : userVars.keySet())
{
System.out.println("Name: " + varName + " | Value: " + userVars.get(varName));
}
getVariable(java.lang.String),
SmartFoxClient.setUserVariables(java.util.Map) public void setVariables(java.util.Map<java.lang.String,SFSVariable> vars)
public void clearVariables()
public void setIsSpectator(boolean b)
public boolean isSpectator()
true if the user is a spectator.
Example
if (user.isSpectator())
{
System.out.println("The user is a spectator");
}
public void setModerator(boolean b)
public boolean isModerator()
true if the user is a Moderator.
Example
if (user.isModerator())
{
System.out.println("The user is a Moderator");
}
public int getPlayerId()
Example
System.out.println("The user's player id is " + user.getPlayerId());
public void setPlayerId(int pid)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||