Class SFSUserManager

  • All Implemented Interfaces:
    IUserManager

    public class SFSUserManager
    extends java.lang.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:
    SmartFox.getUserManager()
    • Constructor Summary

      Constructors 
      Constructor Description
      SFSUserManager​(ISmartFox smartFox)
      Creates a new SFSUserManager instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addUser​(User user)
      * API internal usage only *
      boolean containsUser​(User user)
      Indicates whether a user exists in the local users list or not.
      boolean containsUserId​(int userId)
      Indicates whether a user exists in the local users list or not from the id.
      boolean containsUserName​(java.lang.String userName)
      Indicates whether a user exists in the local users list or not from the name.
      ISmartFox getSmartFox()
      * API internal usage only *
      User getUserById​(int userId)
      Retrieves a User object from its id property.
      User getUserByName​(java.lang.String userName)
      Retrieves a User object from its name property.
      int getUserCount()
      Returns the total number of users in the local users list.
      java.util.List<User> getUserList()
      Get the whole list of users inside the Rooms joined by the client.
      void removeUser​(User user)
      * API internal usage only *
      void removeUserById​(int id)
      * API internal usage only *
      void replaceAll​(java.util.List<User> userList)
      * API internal usage only *
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SFSUserManager

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

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

        Parameters:
        smartFox - An instance of the SmartFoxServer 2X client API main SmartFox class.
        See Also:
        SmartFox.getUserManager()
    • Method Detail

      • containsUserName

        public boolean containsUserName​(java.lang.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:
        User.getName()
      • 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:
        User.getId()
      • 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​(java.lang.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:
        User.getName(), IUserManager.getUserById(int)
      • removeUserById

        public void removeUserById​(int id)
        Description copied from interface: IUserManager
        * API internal usage only *
        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 java.util.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.
      • replaceAll

        public void replaceAll​(java.util.List<User> userList)
        Description copied from interface: IUserManager
        * API internal usage only *
        Specified by:
        replaceAll in interface IUserManager