Class SFSUserManager

java.lang.Object
sfs3.client.entities.managers.SFSUserManager
All Implemented Interfaces:
IUserManager

public class SFSUserManager extends Object implements IUserManager
The SFSUserManager class is the entity in charge of managing the local (client-side) users list. It keeps track of all the users that are currently joined in the same Rooms of the current user. It also provides utility methods to look for users by name and id.
See Also:
  • Field Details

    • log

      protected org.slf4j.Logger log
    • smartFox

      protected ISmartFox smartFox
  • Constructor Details

    • SFSUserManager

      public SFSUserManager(ISmartFox smartFox)
      Creates a new SFSUserManager instance.

      NOTE: developers never instantiate a SFSUserManager manually: this is done by the SmartFoxServer 3 API internally. A reference to the existing instance can be retrieved using the SmartFox.getUserManager() method.

      Parameters:
      smartFox - An instance of the SmartFoxServer 3 client API main SmartFox class.
      See Also:
  • Method Details

    • containsUserName

      public boolean containsUserName(String userName)
      Description copied from interface: IUserManager
      Indicates whether a user exists in the local users list or not from the name.
      Specified by:
      containsUserName in interface IUserManager
      Parameters:
      userName - The name of the user whose presence in the users list is to be tested.
      Returns:
      true if the passed user exists in the users list.
      See Also:
    • containsUserId

      public boolean containsUserId(int userId)
      Description copied from interface: IUserManager
      Indicates whether a user exists in the local users list or not from the id.
      Specified by:
      containsUserId in interface IUserManager
      Parameters:
      userId - The id of the user whose presence in the users list is to be tested.
      Returns:
      true if the passed user exists in the users list.
      See Also:
    • containsUser

      public boolean containsUser(User user)
      Description copied from interface: IUserManager
      Indicates whether a user exists in the local users list or not.
      Specified by:
      containsUser in interface IUserManager
      Parameters:
      user - The User object representing the user whose presence in the users list is to be tested.
      Returns:
      true if the passed user exists in the users list.
    • getUserByName

      public User getUserByName(String userName)
      Description copied from interface: IUserManager
      Retrieves a User object from its name property.
      Specified by:
      getUserByName in interface IUserManager
      Parameters:
      userName - The name of the user to be found.
      Returns:
      The User object representing the user, or null if no user with the passed name exists in the local users list.
      See Also:
    • getUserById

      public User getUserById(int userId)
      Description copied from interface: IUserManager
      Retrieves a User object from its id property.
      Specified by:
      getUserById in interface IUserManager
      Parameters:
      userId - The id of the user to be found.
      Returns:
      The User object representing the user, or null if no user with the passed id exists in the local users list.
      See Also:
    • addUser

      public void addUser(User user)
      Specified by:
      addUser in interface IUserManager
    • addUserInternal

      protected void addUserInternal(User user)
    • removeUser

      public void removeUser(User user)
      Specified by:
      removeUser in interface IUserManager
    • removeUserById

      public void removeUserById(int id)
      Specified by:
      removeUserById in interface IUserManager
    • getUserCount

      public int getUserCount()
      Description copied from interface: IUserManager
      Returns the total number of users in the local users list.
      Specified by:
      getUserCount in interface IUserManager
    • getUserList

      public List<User> getUserList()
      Description copied from interface: IUserManager
      Get the whole list of users inside the Rooms joined by the client.
      Specified by:
      getUserList in interface IUserManager
      Returns:
      The list of User objects representing the users in the local users list.
    • getSmartFox

      public ISmartFox getSmartFox()
      Specified by:
      getSmartFox in interface IUserManager