public class SFSUser extends java.lang.Object implements User
Also each User provides a number of essential services:
Constructor and Description |
---|
SFSUser(ISession session) |
SFSUser(java.lang.String name,
ISession session) |
Modifier and Type | Method and Description |
---|---|
void |
addCreatedRoom(Room room) |
void |
addJoinedRoom(Room room) |
void |
addPersistentRoomVarReference(Room target) |
boolean |
containsProperty(java.lang.Object key)
Checks whether a custom property exists or not
|
boolean |
containsVariable(java.lang.String varName)
Checks whether or not the User has a specific UserVariable
|
void |
disconnect(IDisconnectionReason reason) |
boolean |
equals(java.lang.Object obj) |
com.smartfoxserver.v2.util.IAdminHelper |
getAdminHelper() |
int |
getBadWordsWarnings() |
BuddyProperties |
getBuddyProperties()
Get the BuddyProperty object
|
Country |
getCountry()
If the geolocation service is enabled in the Zone it will return the location of the user
|
java.util.List<Room> |
getCreatedRooms()
Get a list of Rooms created by this User
|
MMORoom |
getCurrentMMORoom() |
java.lang.String |
getDump()
Return a full dump of the User properties, useful for debugging
|
int |
getFloodWarnings() |
int |
getId()
Get the unique user ID
|
java.lang.String |
getIpAddress()
Return the User IP address
|
java.util.List<Room> |
getJoinedRooms()
A list of Rooms currently joined by the User
|
Room |
getLastJoinedRoom()
A reference to the last Room that was joined by this User
|
long |
getLastLoginTime() |
java.util.List<BaseMMOItem> |
getLastMMOItemsList() |
java.util.List<User> |
getLastProxyList() |
long |
getLastRequestTime() |
long |
getLoginTime()
Get the user login time (Unix timestamp)
|
int |
getMaxAllowedVariables()
Get the maximum allowed User Variables for this User
|
java.lang.String |
getName()
Get the User name
|
int |
getOwnedRoomsCount()
Get the number of Rooms created by the User
|
java.util.Set<java.lang.Integer> |
getPersistentRoomVarReferences() |
int |
getPlayerId()
Get the playerId of the User (if applicable).
|
int |
getPlayerId(Room room)
Get the playerId for the User in a specific Room
|
java.util.Map<Room,java.lang.Integer> |
getPlayerIds()
Get a map of playerId(s) per Room
This method can be used when a player is currently engaged in multiple games at the same time |
short |
getPrivilegeId()
Return the Privilege ID of the User.
|
java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> |
getProperties()
Get the map with all User properties
|
java.lang.Object |
getProperty(java.lang.Object key)
Get any custom property attached to this User.
|
int |
getReconnectionSeconds() |
ISession |
getSession()
Get the session object linked to this User
|
java.util.List<java.lang.String> |
getSubscribedGroups()
Get a list of Room Groups subscribed by the User
|
ISFSArray |
getUserVariablesData() |
UserVariable |
getVariable(java.lang.String varName)
Return a UserVariable.
|
java.util.List<UserVariable> |
getVariables()
Obtain the full list of UserVariables
|
int |
getVariablesCount()
Return the number of UserVariables for this User
|
Zone |
getZone()
Get the Zone where the User is currently logged in
|
boolean |
isBeingKicked() |
boolean |
isConnected()
Check if the User is connected
|
boolean |
isJoinedInRoom(Room room)
Check if a User is joined in a Room
|
boolean |
isJoining() |
boolean |
isLocal()
Returns true if the User is connected to the local cluster node
|
boolean |
isNpc()
Returns the NPC flag
|
boolean |
isPlayer()
Check if the User is a Player in the current Room (only for Game Rooms)
|
boolean |
isPlayer(Room room)
Check if the User is Player in a specific Room
|
boolean |
isSpectator()
Check if the User is a Spectator in the current Room (only for Game Rooms)
|
boolean |
isSpectator(Room room)
Check if the User is Spectator in a specific Room
|
boolean |
isSubscribedToGroup(java.lang.String id)
Check if the User is subscribed to a certain Room Group
|
boolean |
isSuperUser()
Check if the User has SuperUser capabilities (kicking/banning etc...)
|
void |
removeCreatedRoom(Room room) |
void |
removeJoinedRoom(Room room) |
void |
removeProperty(java.lang.Object key)
Removes a custom property
|
void |
removeVariable(java.lang.String varName) |
void |
setAdminHelper(com.smartfoxserver.v2.util.IAdminHelper adminHelper) |
void |
setBadWordsWarnings(int badWordsWarnings) |
void |
setBeingKicked(boolean flag) |
void |
setConnected(boolean flag) |
void |
setFloodWarnings(int floodWarnings) |
void |
setJoining(boolean flag) |
void |
setLastLoginTime(long lastLoginTime) |
void |
setLastMMOItemsList(java.util.List<BaseMMOItem> mmoItemsList) |
void |
setLastProxyList(java.util.List<User> proxyList) |
void |
setLastRequestTime(long lastRequestTime) |
void |
setMaxAllowedVariables(int max) |
void |
setName(java.lang.String name)
DO NOT use this method
User names cannot be changed at runtime: they are unique and decided at login time exclusively.
|
void |
setPlayerId(int id,
Room room) |
void |
setPrivilegeId(short id) |
void |
setProperty(java.lang.Object key,
java.lang.Object val)
Attach a custom (server-side only) property to the User object
|
void |
setReconnectionSeconds(int seconds) |
void |
setVariable(UserVariable var) |
void |
setVariables(java.util.List<UserVariable> userVariables) |
void |
setZone(Zone currentZone) |
void |
subscribeGroup(java.lang.String id) |
ISFSArray |
toSFSArray() |
ISFSArray |
toSFSArray(Room room) |
java.lang.String |
toString() |
void |
unsubscribeGroup(java.lang.String id) |
void |
updateLastRequestTime() |
public SFSUser(ISession session)
public SFSUser(java.lang.String name, ISession session)
public BuddyProperties getBuddyProperties()
User
getBuddyProperties
in interface User
public int getId()
User
public short getPrivilegeId()
User
getPrivilegeId
in interface User
public void setPrivilegeId(short id)
setPrivilegeId
in interface User
public boolean isSuperUser()
User
isSuperUser
in interface User
public boolean isConnected()
User
isConnected
in interface User
public boolean isLocal()
User
public void setConnected(boolean flag)
setConnected
in interface User
public void setJoining(boolean flag)
setJoining
in interface User
public java.lang.String getIpAddress()
User
getIpAddress
in interface User
public int getMaxAllowedVariables()
User
getMaxAllowedVariables
in interface User
public void setMaxAllowedVariables(int max)
setMaxAllowedVariables
in interface User
public void addCreatedRoom(Room room)
addCreatedRoom
in interface User
public java.util.List<Room> getCreatedRooms()
User
getCreatedRooms
in interface User
public void removeCreatedRoom(Room room)
removeCreatedRoom
in interface User
public void addJoinedRoom(Room room)
addJoinedRoom
in interface User
public void removeJoinedRoom(Room room)
removeJoinedRoom
in interface User
public int getOwnedRoomsCount()
User
getOwnedRoomsCount
in interface User
public void subscribeGroup(java.lang.String id)
subscribeGroup
in interface User
public void unsubscribeGroup(java.lang.String id)
unsubscribeGroup
in interface User
public java.util.List<java.lang.String> getSubscribedGroups()
User
getSubscribedGroups
in interface User
public boolean isSubscribedToGroup(java.lang.String id)
User
isSubscribedToGroup
in interface User
id
- the id of the grouppublic void disconnect(IDisconnectionReason reason)
disconnect
in interface User
public boolean isNpc()
User
public java.util.List<Room> getJoinedRooms()
User
getJoinedRooms
in interface User
public Zone getZone()
User
public Room getLastJoinedRoom()
User
getLastJoinedRoom
in interface User
public boolean isJoinedInRoom(Room room)
User
isJoinedInRoom
in interface User
room
- the Roompublic long getLoginTime()
User
getLoginTime
in interface User
public void setLastLoginTime(long lastLoginTime)
setLastLoginTime
in interface User
public java.lang.String getName()
User
public void setName(java.lang.String name)
User
public int getPlayerId()
User
getPlayerId
in interface User
public int getPlayerId(Room room)
User
getPlayerId
in interface User
User.getPlayerId()
public java.util.Map<Room,java.lang.Integer> getPlayerIds()
User
getPlayerIds
in interface User
User.getPlayerId()
public void setPlayerId(int id, Room room)
setPlayerId
in interface User
public boolean isPlayer()
User
public boolean isSpectator()
User
isSpectator
in interface User
public boolean isPlayer(Room room)
User
public boolean isSpectator(Room room)
User
isSpectator
in interface User
room
- the rooompublic java.lang.Object getProperty(java.lang.Object key)
User
getProperty
in interface User
public java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> getProperties()
User
getProperties
in interface User
public void setProperty(java.lang.Object key, java.lang.Object val)
User
setProperty
in interface User
key
- the property nameval
- the property valuepublic boolean containsProperty(java.lang.Object key)
User
containsProperty
in interface User
key
- the name of the propertypublic void removeProperty(java.lang.Object key)
User
removeProperty
in interface User
key
- the name of the propertypublic ISession getSession()
User
getSession
in interface User
public int getVariablesCount()
User
getVariablesCount
in interface User
public UserVariable getVariable(java.lang.String varName)
User
getVariable
in interface User
varName
- the name of the variablepublic void setVariable(UserVariable var) throws SFSVariableException
setVariable
in interface User
SFSVariableException
public void setVariables(java.util.List<UserVariable> userVariables) throws SFSVariableException
setVariables
in interface User
SFSVariableException
public boolean containsVariable(java.lang.String varName)
User
containsVariable
in interface User
varName
- the name of the variablepublic java.util.List<UserVariable> getVariables()
User
getVariables
in interface User
public void removeVariable(java.lang.String varName)
removeVariable
in interface User
public java.lang.String toString()
toString
in class java.lang.Object
public long getLastRequestTime()
getLastRequestTime
in interface User
public void updateLastRequestTime()
updateLastRequestTime
in interface User
public void setLastRequestTime(long lastRequestTime)
setLastRequestTime
in interface User
public int getBadWordsWarnings()
getBadWordsWarnings
in interface User
public void setBadWordsWarnings(int badWordsWarnings)
setBadWordsWarnings
in interface User
public int getFloodWarnings()
getFloodWarnings
in interface User
public void setFloodWarnings(int floodWarnings)
setFloodWarnings
in interface User
public long getLastLoginTime()
public boolean isBeingKicked()
isBeingKicked
in interface User
public void setBeingKicked(boolean flag)
setBeingKicked
in interface User
public ISFSArray getUserVariablesData()
getUserVariablesData
in interface User
public int getReconnectionSeconds()
getReconnectionSeconds
in interface User
public void setReconnectionSeconds(int seconds)
setReconnectionSeconds
in interface User
public ISFSArray toSFSArray(Room room)
toSFSArray
in interface User
public ISFSArray toSFSArray()
toSFSArray
in interface User
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String getDump()
User
public com.smartfoxserver.v2.util.IAdminHelper getAdminHelper()
public void setAdminHelper(com.smartfoxserver.v2.util.IAdminHelper adminHelper)
public java.util.List<User> getLastProxyList()
getLastProxyList
in interface User
public void setLastProxyList(java.util.List<User> proxyList)
setLastProxyList
in interface User
public java.util.List<BaseMMOItem> getLastMMOItemsList()
getLastMMOItemsList
in interface User
public void setLastMMOItemsList(java.util.List<BaseMMOItem> mmoItemsList)
setLastMMOItemsList
in interface User
public MMORoom getCurrentMMORoom()
getCurrentMMORoom
in interface User
public Country getCountry()
User
getCountry
in interface User
public void addPersistentRoomVarReference(Room target)
addPersistentRoomVarReference
in interface User
public java.util.Set<java.lang.Integer> getPersistentRoomVarReferences()
getPersistentRoomVarReferences
in interface User