Class SFSUser
- All Implemented Interfaces:
User
The SmartFoxServer 3 client API are not aware of all the clients (users) connected to the server, but only of those that are in the same Rooms joined by the current client; this reduces the traffic between the client and the server considerably. In order to interact with other users the client should join other Rooms or use the Buddy List system to keep track of and interact with friends.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Vec3Dprotected intprotected booleanprotected Stringprotected intprotected IUserManagerprotected Map<String, UserVariable> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsVariable(String name) Indicates whether this user has the specified User Variable set or not.booleanstatic UserfromSFSArray(ISFSArray sfsa) static UserfromSFSArray(ISFSArray sfsa, Room room) Returns the entry point within the User's AOI where this client "appeared" with the last PROXIMITY_LIST_UPDATE event.intgetId()The id of this user.getName()The name of this user.intReturns the id of this user as a player in a Game Room.intgetPlayerId(Room room) Returns the playerId value of this user in the passed Room.intReturns the id which identifies the privilege level of this user.Returns a reference to the User Manager which manages this user.getVariable(String varName) Retrieves a User Variable from its name.Retrieves all the User Variables of this user.inthashCode()booleanisAdmin()Indicates whether this user logged in as an administrator or not.booleanisGuest()Indicates whether this user logged in as a guest or not.booleanisItMe()Indicates if this User object represents the current client.booleanisJoinedInRoom(Room room) Indicates whether this user joined the passed Room or not.booleanIndicates whether this user logged in as a moderator or not.booleanisPlayer()Indicates whether this user is a player (playerId greater than0) in the last joined Room or not.booleanisPlayerInRoom(Room room) Indicates whether this user is a player (playerId greater than0) in the passed Room or not.booleanIndicates whether this user is a spectator (playerId lower than0) in the last joined Room or not.booleanisSpectatorInRoom(Room room) Indicates whether this user is a spectator (playerId lower than0) in the passed Room or not.booleanIndicates whether this user logged in as a standard user or not.voidremovePlayerId(Room room) voidreplaceVariables(List<UserVariable> vars) voidsetAOIEntryPoint(Vec3D aoiEntryPoint) voidsetPlayerId(int id, Room room) voidsetPrivilegeId(int privilegeId) voidsetUserManager(IUserManager userManager) voidsetVariable(UserVariable userVariable) voidsetVariables(List<? extends UserVariable> userVariables) toString()Returns a string that contains the user id, name and a boolean indicating if the SFSUser object represents the current client.
-
Field Details
-
id
protected int id -
privilegeId
protected int privilegeId -
name
-
isItMe
protected boolean isItMe -
variables
-
playerIdByRoomId
-
userManager
-
aoiEntryPoint
-
-
Constructor Details
-
SFSUser
-
SFSUser
Creates a new SFSUser instance.NOTE: never instantiate a SFSUser manually, this is done by the SmartFoxServer 3 API internally.
- Parameters:
id- The user id.name- The user name.isItMe- Iftrue, the user being created corresponds to the current client.
-
-
Method Details
-
fromSFSArray
- Internal
-
fromSFSArray
- Internal
-
getId
public int getId()Description copied from interface:UserThe id of this user. It is unique and it is generated by the server when the user is created. -
getName
Description copied from interface:UserThe name of this user. Two users in the same Zone can't have the same name (case sensitive) -
getPlayerId
public int getPlayerId()Description copied from interface:UserReturns the id of this user as a player in a Game Room.This property differs from the id property and it's used to indicate which player number is assigned to a user inside a Game Room. For example, in a Game Room for 5 players the first client joining it will have playerId equal to
1, the second will have it equal to2and so forth. When a user leaves the Room the player slot is freed up and the next user joining the Room will take it.The playerId property applies to Game Rooms only; in standard Rooms it is always
0. Also, in Game Rooms a playerId value lower than0indicates that the user is a spectator.If the user is inside multiple Game Rooms at the same time, a different playerId value will be assigned to him in each Room. In this case this property returns the value corresponding to the last joined Room; in order to obtain the playerId value in a specific Room, use the getPlayerId() method.
- Specified by:
getPlayerIdin interfaceUser- See Also:
-
isPlayer
public boolean isPlayer()Description copied from interface:UserIndicates whether this user is a player (playerId greater than0) in the last joined Room or not. Non-Game Rooms always returnfalse.If the user is inside multiple Game Rooms at the same time, use the isPlayerInRoom() method.
-
isSpectator
public boolean isSpectator()Description copied from interface:UserIndicates whether this user is a spectator (playerId lower than0) in the last joined Room or not. Non-Game Rooms always returnfalse.If the user is inside multiple Game Rooms at the same time, use the isSpectatorInRoom() method.
- Specified by:
isSpectatorin interfaceUser- See Also:
-
getPlayerId
Description copied from interface:UserReturns the playerId value of this user in the passed Room. See the playerId property description for more informations.- Specified by:
getPlayerIdin interfaceUser- Parameters:
room- The Room object representing the Room to retrieve the player id from.- Returns:
- The playerId of this user in the passed Room.
- See Also:
-
setPlayerId
- Specified by:
setPlayerIdin interfaceUser- Internal
-
removePlayerId
- Specified by:
removePlayerIdin interfaceUser- Internal
-
getPrivilegeId
public int getPrivilegeId()Description copied from interface:UserReturns the id which identifies the privilege level of this user.NOTE: setting the privilegeId property manually has no effect on the server and can disrupt the API functioning. Privileges are assigned to the user by the server when the user logs in.
- Specified by:
getPrivilegeIdin interfaceUser- See Also:
-
setPrivilegeId
public void setPrivilegeId(int privilegeId) - Specified by:
setPrivilegeIdin interfaceUser- Internal
-
getUserManager
Description copied from interface:UserReturns a reference to the User Manager which manages this user.NOTE: setting the userManager property manually has no effect on the server and can disrupt the API functioning.
- Specified by:
getUserManagerin interfaceUser
-
setUserManager
- Specified by:
setUserManagerin interfaceUser- Internal
-
isGuest
public boolean isGuest()Description copied from interface:UserIndicates whether this user logged in as a guest or not. Guest users have the privilegeId property se to UserPrivileges.GUEST. -
isStandardUser
public boolean isStandardUser()Description copied from interface:UserIndicates whether this user logged in as a standard user or not. Standard users have the privilegeId property se to UserPrivileges.STANDARD.- Specified by:
isStandardUserin interfaceUser- Returns:
trueif this user is a standard user.- See Also:
-
isModerator
public boolean isModerator()Description copied from interface:UserIndicates whether this user logged in as a moderator or not. Moderator users have the privilegeId property set to UserPrivileges.MODERATOR.- Specified by:
isModeratorin interfaceUser- Returns:
trueif this user is a moderator.- See Also:
-
isAdmin
public boolean isAdmin()Description copied from interface:UserIndicates whether this user logged in as an administrator or not. Administrator users have the privilegeId property set to UserPrivileges.ADMINISTRATOR. -
isPlayerInRoom
Description copied from interface:UserIndicates whether this user is a player (playerId greater than0) in the passed Room or not. Non-Game Rooms always returnfalse.If a user can join one Game Rooms at a time only, use the isPlayer property.
- Specified by:
isPlayerInRoomin interfaceUser- Parameters:
room- The Room object representing the Room where to check if this user is a player.- Returns:
trueif this user is a player in the passed Room.- See Also:
-
isSpectatorInRoom
Description copied from interface:UserIndicates whether this user is a spectator (playerId lower than0) in the passed Room or not. Non-Game Rooms always returnfalse.If a user can join one Game Rooms at a time only, use the isSpectator property.
- Specified by:
isSpectatorInRoomin interfaceUser- Parameters:
room- The Room object representing the Room where to check if this user is a spectator.- Returns:
trueif this user is a spectator in the passed Room.- See Also:
-
isJoinedInRoom
Description copied from interface:UserIndicates whether this user joined the passed Room or not.- Specified by:
isJoinedInRoomin interfaceUser- Parameters:
room- The Room object representing the Room where to check the user presence.- Returns:
trueif this user is inside the passed Room.
-
isItMe
public boolean isItMe()Description copied from interface:UserIndicates if this User object represents the current client. -
getVariables
Description copied from interface:UserRetrieves all the User Variables of this user.- Specified by:
getVariablesin interfaceUser- Returns:
- The list of UserVariable objects associated with the user.
- See Also:
-
getVariable
Description copied from interface:UserRetrieves a User Variable from its name.- Specified by:
getVariablein interfaceUser- Parameters:
varName- The name of the User Variable to be retrieved.- Returns:
- The UserVariable object representing the User Variable, or
nullif no User Variable with the passed name is associated with this user. - See Also:
-
setVariable
- Specified by:
setVariablein interfaceUser
-
setVariables
- Specified by:
setVariablesin interfaceUser- Internal
-
containsVariable
Description copied from interface:UserIndicates whether this user has the specified User Variable set or not.- Specified by:
containsVariablein interfaceUser- Parameters:
name- The name of the User Variable whose existence must be checked.- Returns:
trueif a User Variable with the passed name is set for this user.
-
getAOIEntryPoint
Description copied from interface:UserReturns the entry point within the User's AOI where this client "appeared" with the last PROXIMITY_LIST_UPDATE event. This field is populated only if the MMORoom is configured to receive this data.- Specified by:
getAOIEntryPointin interfaceUser- See Also:
-
setAOIEntryPoint
- Specified by:
setAOIEntryPointin interfaceUser
-
equals
-
hashCode
public int hashCode() -
toString
Returns a string that contains the user id, name and a boolean indicating if the SFSUser object represents the current client. -
replaceVariables
- Internal
-