Class SFS2X.Managers.BuddyManager

The manager of the current user's Buddy List system.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new BuddyManager instance.

Method Summary

Class Detail

SFS2X.Managers.BuddyManager(sfs)
Creates a new BuddyManager instance.

This class keeps track of all the user's buddies, their state and their Buddy Variables. It also provides utility methods to set the user's properties when he is part of the buddies list of other users.

IMPORTANT: no Buddy List related operations are allowed until the system is initialized using the InitBuddyListRequest request.

NOTE: developers never istantiate a BuddyManager manually: this is done by the SmartFoxServer 2X API internally. A reference to the existing instance can be retrieved using the SmartFox.buddyManager property.

Parameters:
{SmartFox} sfs
An instance of the SmartFoxServer 2X client API main SmartFox class.
See also:
SFS2X.SmartFox#buddyManager

Method Detail

  • {Boolean} containsBuddy(name)
    Indicates whether a buddy exists in user's buddy list or not.
    Parameters:
    {String} name
    The name of the buddy whose presence in the buddy list is to be checked.
    Returns:
    {Boolean} true if the specified buddy exists in the buddy list.
    See also:
    SFS2X.Entities.SFSBuddy#name
  • {SFSBuddy} getBuddyById(id)
    Retrieves a SFSBuddy object from its id property.
    Parameters:
    {Number} id
    The id of the buddy to be found.
    Returns:
    {SFSBuddy} The SFSBuddy object representing the buddy, or null if no buddy with the passed id exists in the buddy list.
    See also:
    SFS2X.Entities.SFSBuddy#id
  • {SFSBuddy} getBuddyByName(name)
    Retrieves a SFSBuddy object from its name property.
    Parameters:
    {String} name
    The name of the buddy to be found.
    Returns:
    {SFSBuddy} The SFSBuddy object representing the buddy, or null if no buddy with the passed name exists in the buddy list.
    See also:
    SFS2X.Entities.SFSBuddy#name
  • {SFSBuddy} getBuddyByNickName(nickName)
    Retrieves a SFSBuddy object using its getNickName method.
    Parameters:
    {String} nickName
    The nickname of the buddy to be found.
    Returns:
    {SFSBuddy} The SFSBuddy object representing the buddy, or null if no buddy with the passed nickname exists in the buddies list.
    See also:
    SFS2X.Entities.SFSBuddy#getNickName
  • {Array} getBuddyList()
    Returns a list of SFSBuddy objects representing all the buddies in the user's buddy list.
    Returns:
    {Array} A list of SFSBuddy objects representing all the buddies.
    See also:
    SFS2X.Requests.BuddyList.InitBuddyListRequest
  • {Array} getBuddyStates()
    Returns a list of strings representing the available custom buddy states.

    The custom states are received by the client upon initialization of the Buddy List system. They can be configured by means of the SmartFoxServer 2X Administration Tool.

    Returns:
    {Array} The list of available custom buddy states in the Buddy List system.
    See also:
    SFS2X.Entities.SFSBuddy#getState
  • {String} getMyNickName()
    Returns the current user's nickname (if set). If the nickname was never set before, null is returned.

    As the nickname of a user in a buddy list is handled by means of a reserved Buddy Variable (see ReservedBuddyVariables class), it can be set using the SetBuddyVariablesRequest request.

    Returns:
    {String} The user nickname in the Buddy List system.
    See also:
    SFS2X.Entities.SFSBuddy#getNickName
    SFS2X.Entities.Variables.ReservedBuddyVariables
    SFS2X.Requests.BuddyList.SetBuddyVariablesRequest
  • {Boolean} getMyOnlineState()
    Returns the current user's online/offline state.

    If true, the user appears to be online in the buddy list of other users who have him as a buddy.
    The online state of a user in a buddy list is handled by means of a reserved Buddy Variable (see ReservedBuddyVariables class); it can be changed using the dedicated GoOnlineRequest request.

    Returns:
    {Boolean} true if the user is online in the Buddy List system.
    See also:
    SFS2X.Entities.SFSBuddy#isOnline
    SFS2X.Entities.Variables.ReservedBuddyVariables
    SFS2X.Requests.BuddyList.GoOnlineRequest
  • {String} getMyState()
    Returns the current user's custom state (if set). Examples of custom states are "Available", "Busy", "Be right back", etc. If the custom state was never set before, null is returned.

    As the custom state of a user in a buddy list is handled by means of a reserved Buddy Variable (see ReservedBuddyVariables class), it can be set using the SetBuddyVariablesRequest request.

    Returns:
    {String} The user state in the Buddy List system.
    See also:
    SFS2X.Entities.SFSBuddy#getState
    SFS2X.Entities.Variables.ReservedBuddyVariables
    SFS2X.Requests.BuddyList.SetBuddyVariablesRequest
  • getMyVariable(varName)
    Retrieves a Buddy Variable set for the current user from its name.
    Parameters:
    {String} varName
    The name of the Buddy Variable to be retrieved.
    Returns:
    The SFSBuddyVariable object representing the Buddy Variable, or null if no Buddy Variable with the passed name is associated to the current user.
    See also:
    SFS2X.Requests.BuddyList.SetBuddyVariablesRequest
  • {Array} getMyVariables()
    Returns all the Buddy Variables set for the current user.
    Returns:
    {Array} A list of SFSBuddyVariable objects representing all the Buddy Variables set for the user.
    See also:
    SFS2X.Entities.Variables.SFSBuddyVariable
  • {Array} getOfflineBuddies()
    Returns a list of SFSBuddy objects representing all the offline buddies in the user's buddy list.
    Returns:
    {Array} A list of SFSBuddy objects representing the offline buddies.
    See also:
    SFS2X.Entities.SFSBuddy#isOnline
  • {Array} getOnlineBuddies()
    Returns a list of SFSBuddy objects representing all the online buddies in the user's buddy list.
    Returns:
    {Array} A list of SFSBuddy objects representing the online buddies.
    See also:
    SFS2X.Entities.SFSBuddy#isOnline
  • {Boolean} isInited()
    Indicates whether the client's Buddy List system is initialized or not. If not, an InitBuddyListRequest request should be sent to the server in order to retrieve the persistent Buddy List data.
    Returns:
    {Boolean} true if the Buddy List system is initialized in the client.
    See also:
    SFS2X.Requests.BuddyList.InitBuddyListRequest