Package sfs2x.client.entities.managers
Class SFSUserManager
- java.lang.Object
-
- sfs2x.client.entities.managers.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 *
-
-
-
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 interfaceIUserManager
- 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 interfaceIUserManager
- 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 interfaceIUserManager
- 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 interfaceIUserManager
- 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)
-
getUserById
public User getUserById(int userId)
Description copied from interface:IUserManager
Retrieves a User object from its id property.- Specified by:
getUserById
in interfaceIUserManager
- 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:
User.getId()
,IUserManager.getUserByName(java.lang.String)
-
addUser
public void addUser(User user)
Description copied from interface:IUserManager
* API internal usage only *- Specified by:
addUser
in interfaceIUserManager
-
removeUser
public void removeUser(User user)
Description copied from interface:IUserManager
* API internal usage only *- Specified by:
removeUser
in interfaceIUserManager
-
removeUserById
public void removeUserById(int id)
Description copied from interface:IUserManager
* API internal usage only *- Specified by:
removeUserById
in interfaceIUserManager
-
getUserCount
public int getUserCount()
Description copied from interface:IUserManager
Returns the total number of users in the local users list.- Specified by:
getUserCount
in interfaceIUserManager
-
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 interfaceIUserManager
- Returns:
- The list of User objects representing the users in the local users list.
-
getSmartFox
public ISmartFox getSmartFox()
Description copied from interface:IUserManager
* API internal usage only *- Specified by:
getSmartFox
in interfaceIUserManager
-
replaceAll
public void replaceAll(java.util.List<User> userList)
Description copied from interface:IUserManager
* API internal usage only *- Specified by:
replaceAll
in interfaceIUserManager
-
-