Package com.smartfoxserver.entities
Interface User
- All Known Implementing Classes:
SFSUser
public interface User
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCreatedRoom(Room room) voidaddJoinedRoom(Room room) voidaddPersistentRoomVarReference(Room target) booleancontainsProperty(Object key) Checks whether a custom property exists or notbooleancontainsVariable(String varName) Checks whether or not the User has a specific UserVariable setvoiddisconnect(IDisconnectionReason reason) com.smartfoxserver.entities.audio.AudioStreamInfointGet the BuddyProperty objectBy default each client API sends a different "signature" identifying the client technology (e.g.If the geolocation service is enabled in the Zone it will return the location of the userGet a list of Rooms created by this UsergetDump()Return a full dump of the User properties, useful for debuggingintintintgetId()Get the unique user IDReturn the User IP addressA list of Rooms currently joined by the UserA reference to the last Room that was joined by this UserlonglongGet the user login time (Unix timestamp in milliseconds)intGet the maximum allowed User Variables for this UsergetName()Get the User nameintGet the number of Rooms created by the UserintGet the playerId of the User (if applicable).intgetPlayerId(Room room) Get the playerId for the User in a specific RoomGet a map of playerId(s) per Room
This method can be used when a player is currently engaged in multiple games at the same timeshortReturn the Privilege ID of the User.Get the map with all User propertiesgetProperty(Object key) Get any custom property attached to this User.intGet the session object linked to this UserGet a list of Room Groups subscribed by the UsergetVariable(String key) Returns the UserVariable with the provided name.Obtain the full list of UserVariablesintReturn the number of UserVariables for this UsergetZone()Get the Zone where the User is currently logged inbooleanisAdmin()booleanbooleanCheck if the User is connectedbooleanisJoinedInRoom(Room room) Check if a User is joined in a RoombooleanbooleanisNpc()Returns the NPC flagbooleanisPlayer()Check if the User is a Player in the current Room (only for Game Rooms)booleanCheck if the User is Player in a specific RoombooleanCheck if the User is a Spectator in the current Room (only for Game Rooms)booleanisSpectator(Room room) Check if the User is Spectator in a specific RoombooleanisSubscribedToGroup(String groupId) Check if the User is subscribed to a certain Room GroupbooleanCheck if the User has SuperUser privileges (allows to send mod/admin messages and kick/ban Users)voidremoveCreatedRoom(Room room) voidremoveJoinedRoom(Room room) voidremoveProperty(Object key) Removes a custom propertyvoidremoveVariable(String varName) voidsetAudioStreamInfo(com.smartfoxserver.entities.audio.AudioStreamInfo info) voidsetBadWordsWarnings(int count) voidsetBeingKicked(boolean flag) voidsetConnected(boolean flag) voidsetExtFloodWarnings(int count) voidsetFloodWarnings(int count) voidsetJoining(boolean flag) voidsetLastLoginTime(long lastLoginTime) voidsetLastMMOItemsList(List<BaseMMOItem> mmoItemsList) voidsetLastProxyList(List<User> proxyList) voidsetLastRequestTime(long millis) voidsetMaxAllowedVariables(int max) voidvoidsetPlayerId(int id, Room room) voidsetPrivilegeId(short id) voidsetProperty(Object key, Object val) Attach a custom (server-side only) property to the User objectvoidsetReconnectionSeconds(int seconds) voidsetVariable(UserVariable userVariable) voidsetVariables(List<UserVariable> userVariables) voidvoidsubscribeGroup(String groupId) toSFSArray(Room room) voidunsubscribeGroup(String groupId) void
-
Method Details
-
getId
int getId()Get the unique user ID- Returns:
- the user id
-
getSession
ISession getSession()Get the session object linked to this User- Returns:
- the user sessions object
-
getIpAddress
String getIpAddress()Return the User IP address- Returns:
- the IP address
-
getName
String getName()Get the User name- Returns:
- the user name
-
getClientType
String getClientType()By default each client API sends a different "signature" identifying the client technology (e.g. Unity, Godot, Javascript) and version of the API.- Returns:
- the string identifying the type of connected client
-
getBuddyProperties
BuddyProperties getBuddyProperties()Get the BuddyProperty object- Returns:
- the buddy properties
-
setName
- Internal
-
isNpc
boolean isNpc()Returns the NPC flag- Returns:
- true if the user is an NPC
-
getLoginTime
long getLoginTime()Get the user login time (Unix timestamp in milliseconds)- Returns:
- login time
-
setLastLoginTime
void setLastLoginTime(long lastLoginTime) - Internal
-
getLastJoinedRoom
Room getLastJoinedRoom()A reference to the last Room that was joined by this User- Returns:
- the last joined Room
-
getJoinedRooms
A list of Rooms currently joined by the User- Returns:
- the list of Rooms
-
addJoinedRoom
- Internal
-
removeJoinedRoom
- Internal
-
isJoinedInRoom
Check if a User is joined in a Room- Parameters:
room- the Room- Returns:
- true if the User is joined in the passed Room
-
addCreatedRoom
- Internal
-
removeCreatedRoom
- Internal
-
getCreatedRooms
Get a list of Rooms created by this User- Returns:
- the list of Rooms (if any)
-
subscribeGroup
- Internal
- Instead use
SFSApi.subscribeRoomGroup(User, String)
-
unsubscribeGroup
- Internal
- Instead use
SFSApi.subscribeRoomGroup(User, String)
-
getSubscribedGroups
Get a list of Room Groups subscribed by the User- Returns:
- the list of groups
-
isSubscribedToGroup
Check if the User is subscribed to a certain Room Group- Parameters:
groupId- the id of the group- Returns:
- true if the User is currently subscribed to the group
-
getZone
Zone getZone()Get the Zone where the User is currently logged in- Returns:
- the Zone
-
setZone
- Internal
-
getPlayerId
int getPlayerId()Get the playerId of the User (if applicable). The User should be currently joined in a Game Room for this method to return a meaningful value.playerId == 0, if the Room is not a Game Room playerID >0, if the Room is a Game Room
- Returns:
- the player id
-
getPlayerId
Get the playerId for the User in a specific Room- Parameters:
room-- Returns:
- the playerId
- See Also:
-
setPlayerId
- Internal
-
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- Returns:
- the map of playerIds per room
- See Also:
-
isPlayer
boolean isPlayer()Check if the User is a Player in the current Room (only for Game Rooms)- Returns:
- true if the User is a player in the current Room
-
isSpectator
boolean isSpectator()Check if the User is a Spectator in the current Room (only for Game Rooms)- Returns:
- true if the User is a spectator in the current Room
-
isPlayer
Check if the User is Player in a specific Room- Parameters:
room- the Room- Returns:
- true if the User is a player in the specified Room
-
isSpectator
Check if the User is Spectator in a specific Room- Parameters:
room- the Room- Returns:
- true if the User is a spectator in the specified Room
-
isJoining
boolean isJoining()- Internal
-
setJoining
void setJoining(boolean flag) - Internal
-
isConnected
boolean isConnected()Check if the User is connected- Returns:
- true if the user has an active connection
-
setConnected
void setConnected(boolean flag) - Internal
-
isSuperUser
boolean isSuperUser()Check if the User has SuperUser privileges (allows to send mod/admin messages and kick/ban Users)- Returns:
- true if the User has SuperUser capabilities
-
isAdmin
boolean isAdmin()- Returns:
- true if the User is an Administrator
-
getMaxAllowedVariables
int getMaxAllowedVariables()Get the maximum allowed User Variables for this User- Returns:
- the number of variables
-
setMaxAllowedVariables
void setMaxAllowedVariables(int max) - Internal
-
getProperty
Get any custom property attached to this User.- Parameters:
key-- Returns:
- the value
-
getProperties
ConcurrentMap<Object,Object> getProperties()Get the map with all User properties- Returns:
- the map with all User properties
-
setProperty
Attach a custom (server-side only) property to the User object- Parameters:
key- the property nameval- the property value
-
containsProperty
Checks whether a custom property exists or not- Parameters:
key- the name of the property- Returns:
- true if the property exists
-
removeProperty
Removes a custom property- Parameters:
key- the name of the property
-
getOwnedRoomsCount
int getOwnedRoomsCount()Get the number of Rooms created by the User- Returns:
- the number of Rooms created by the User
-
isBeingKicked
boolean isBeingKicked()- Internal
-
setBeingKicked
void setBeingKicked(boolean flag) - Internal
-
getPrivilegeId
short getPrivilegeId()Return the Privilege ID of the User. Default privilege IDs are:- 0: guest
- 1: regular user (default)
- 2: moderator
- 3: administrator
- Returns:
- the privilege id
-
setPrivilegeId
void setPrivilegeId(short id) - Internal
-
getVariable
Returns the UserVariable with the provided name. Returns null if the UserVariable doesn't exist.- Parameters:
key- the name of the variable- Returns:
- the UserVariable
-
getVariables
List<UserVariable> getVariables()Obtain the full list of UserVariables- Returns:
- the list of UserVariables
-
setVariable
- Throws:
SFSVariableException- Internal
-
setVariables
- Throws:
SFSVariableException- Internal
-
removeVariable
- Internal
-
containsVariable
Checks whether or not the User has a specific UserVariable set- Parameters:
varName- the name of the variable- Returns:
- true if the UserVariable exists
-
getVariablesCount
int getVariablesCount()Return the number of UserVariables for this User- Returns:
- the number of UserVariables
-
getBadWordsWarnings
int getBadWordsWarnings()- Internal
-
setBadWordsWarnings
void setBadWordsWarnings(int count) - Internal
-
getFloodWarnings
int getFloodWarnings()- Internal
-
setFloodWarnings
void setFloodWarnings(int count) - Internal
-
getExtFloodWarnings
int getExtFloodWarnings()- Internal
-
setExtFloodWarnings
void setExtFloodWarnings(int count) - Internal
-
getLastRequestTime
long getLastRequestTime()- Internal
-
setLastRequestTime
void setLastRequestTime(long millis) - Internal
-
updateLastRequestTime
void updateLastRequestTime()- Internal
-
getUserVariablesData
ISFSArray getUserVariablesData()- Internal
-
toSFSArray
- Internal
-
toSFSArray
ISFSArray toSFSArray()- Internal
-
disconnect
- Internal
-
getDump
String getDump()Return a full dump of the User properties, useful for debugging- Returns:
- the User debug info
-
getReconnectionSeconds
int getReconnectionSeconds()- Internal
-
setReconnectionSeconds
void setReconnectionSeconds(int seconds) - Internal
-
getLastProxyList
- Internal
-
setLastProxyList
- Internal
-
getLastMMOItemsList
List<BaseMMOItem> getLastMMOItemsList()- Internal
-
setLastMMOItemsList
- Internal
-
getCurrentMMORoom
MMORoom getCurrentMMORoom()- Internal
-
getCountry
Country getCountry()If the geolocation service is enabled in the Zone it will return the location of the user- Returns:
- the location of the user, null if the geolocation DB did not provide a match
- Since:
- 2.12
-
addPersistentRoomVarReference
- Internal
-
getPersistentRoomVarReferences
- Internal
-
getAudioStreamInfo
com.smartfoxserver.entities.audio.AudioStreamInfo getAudioStreamInfo()- Internal
-
setAudioStreamInfo
void setAudioStreamInfo(com.smartfoxserver.entities.audio.AudioStreamInfo info) - Internal
-