Interface User

All Known Implementing Classes:
SFSUser

public interface User
  • 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

      void setName(String name)
      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

      List<Room> getJoinedRooms()
      A list of Rooms currently joined by the User
      Returns:
      the list of Rooms
    • addJoinedRoom

      void addJoinedRoom(Room room)
      Internal
    • removeJoinedRoom

      void removeJoinedRoom(Room room)
      Internal
    • isJoinedInRoom

      boolean isJoinedInRoom(Room room)
      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

      void addCreatedRoom(Room room)
      Internal
    • removeCreatedRoom

      void removeCreatedRoom(Room room)
      Internal
    • getCreatedRooms

      List<Room> getCreatedRooms()
      Get a list of Rooms created by this User
      Returns:
      the list of Rooms (if any)
    • subscribeGroup

      void subscribeGroup(String groupId)
      Internal
      Instead use SFSApi.subscribeRoomGroup(User, String)
    • unsubscribeGroup

      void unsubscribeGroup(String groupId)
      Internal
      Instead use SFSApi.subscribeRoomGroup(User, String)
    • getSubscribedGroups

      List<String> getSubscribedGroups()
      Get a list of Room Groups subscribed by the User
      Returns:
      the list of groups
    • isSubscribedToGroup

      boolean isSubscribedToGroup(String groupId)
      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

      void setZone(Zone zone)
      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

      int getPlayerId(Room room)
      Get the playerId for the User in a specific Room
      Parameters:
      room -
      Returns:
      the playerId
      See Also:
    • setPlayerId

      void setPlayerId(int id, Room room)
      Internal
    • getPlayerIds

      Map<Room,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
      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

      boolean isPlayer(Room room)
      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

      boolean isSpectator(Room room)
      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

      Object getProperty(Object key)
      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

      void setProperty(Object key, Object val)
      Attach a custom (server-side only) property to the User object
      Parameters:
      key - the property name
      val - the property value
    • containsProperty

      boolean containsProperty(Object key)
      Checks whether a custom property exists or not
      Parameters:
      key - the name of the property
      Returns:
      true if the property exists
    • removeProperty

      void removeProperty(Object key)
      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

      UserVariable getVariable(String key)
      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

      void setVariable(UserVariable userVariable) throws SFSVariableException
      Throws:
      SFSVariableException
      Internal
    • setVariables

      void setVariables(List<UserVariable> userVariables) throws SFSVariableException
      Throws:
      SFSVariableException
      Internal
    • removeVariable

      void removeVariable(String varName)
      Internal
    • containsVariable

      boolean containsVariable(String varName)
      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

      ISFSArray toSFSArray(Room room)
      Internal
    • toSFSArray

      ISFSArray toSFSArray()
      Internal
    • disconnect

      void disconnect(IDisconnectionReason reason)
      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

      List<User> getLastProxyList()
      Internal
    • setLastProxyList

      void setLastProxyList(List<User> proxyList)
      Internal
    • getLastMMOItemsList

      List<BaseMMOItem> getLastMMOItemsList()
      Internal
    • setLastMMOItemsList

      void setLastMMOItemsList(List<BaseMMOItem> mmoItemsList)
      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

      void addPersistentRoomVarReference(Room target)
      Internal
    • getPersistentRoomVarReferences

      Set<Integer> getPersistentRoomVarReferences()
      Internal
    • getAudioStreamInfo

      com.smartfoxserver.entities.audio.AudioStreamInfo getAudioStreamInfo()
      Internal
    • setAudioStreamInfo

      void setAudioStreamInfo(com.smartfoxserver.entities.audio.AudioStreamInfo info)
      Internal