Packagecom.smartfoxserver.v2.entities.managers
Classpublic class SFSBuddyManager
InheritanceSFSBuddyManager Inheritance Object
Implements IBuddyManager

The SFSBuddyManager class is the entity in charge of managing the current user's Buddy List system. It 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.

See also

SmartFox.buddyManager


Public Properties
 PropertyDefined By
  buddyList : Array
[read-only] Returns a list of Buddy objects representing all the buddies in the user's buddies list.
SFSBuddyManager
  buddyStates : Array
[read-only] Returns a list of strings representing the available custom buddy states.
SFSBuddyManager
  isInited : Boolean
[read-only] Indicates whether the client's Buddy List system is initialized or not.
SFSBuddyManager
  myNickName : String
[read-only] Returns the current user's nickname (if set).
SFSBuddyManager
  myOnlineState : Boolean
[read-only] Returns the current user's online/offline state.
SFSBuddyManager
  myState : String
[read-only] Returns the current user's custom state (if set).
SFSBuddyManager
  myVariables : Array
[read-only] Returns all the Buddy Variables associated with the current user.
SFSBuddyManager
  offlineBuddies : Array
[read-only] Returns a list of Buddy objects representing all the offline buddies in the user's buddies list.
SFSBuddyManager
  onlineBuddies : Array
[read-only] Returns a list of Buddy objects representing all the online buddies in the user's buddies list.
SFSBuddyManager
Public Methods
 MethodDefined By
  
Creates a new SFSBuddyManager instance.
SFSBuddyManager
  
containsBuddy(name:String):Boolean
Indicates whether a buddy exists in user's buddies list or not.
SFSBuddyManager
  
Retrieves a Buddy object from its id property.
SFSBuddyManager
  
getBuddyByName(name:String):Buddy
Retrieves a Buddy object from its name property.
SFSBuddyManager
  
getBuddyByNickName(nickName:String):Buddy
Retrieves a Buddy object from its nickName property (if set).
SFSBuddyManager
  
Retrieves a Buddy Variable from its name.
SFSBuddyManager
Property Detail
buddyListproperty
buddyList:Array  [read-only]

Returns a list of Buddy objects representing all the buddies in the user's buddies list. The list is null if the Buddy List system is not initialized.


Implementation
    public function get buddyList():Array
buddyStatesproperty 
buddyStates:Array  [read-only]

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.


Implementation
    public function get buddyStates():Array
isInitedproperty 
isInited:Boolean  [read-only]

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.

No Buddy List related operations are allowed until the system is initialized.


Implementation
    public function get isInited():Boolean
myNickNameproperty 
myNickName:String  [read-only]

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.


Implementation
    public function get myNickName():String
myOnlineStateproperty 
myOnlineState:Boolean  [read-only]

Returns the current user's online/offline state. If true, the user appears to be online in the buddies 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.


Implementation
    public function get myOnlineState():Boolean
myStateproperty 
myState:String  [read-only]

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.


Implementation
    public function get myState():String
myVariablesproperty 
myVariables:Array  [read-only]

Returns all the Buddy Variables associated with the current user.


Implementation
    public function get myVariables():Array
offlineBuddiesproperty 
offlineBuddies:Array  [read-only]

Returns a list of Buddy objects representing all the offline buddies in the user's buddies list.


Implementation
    public function get offlineBuddies():Array
onlineBuddiesproperty 
onlineBuddies:Array  [read-only]

Returns a list of Buddy objects representing all the online buddies in the user's buddies list.


Implementation
    public function get onlineBuddies():Array
Constructor Detail
SFSBuddyManager()Constructor
public function SFSBuddyManager(sfs:SmartFox)

Creates a new SFSBuddyManager instance.

NOTE: developers never instantiate a SFSBuddyManager 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
sfs:SmartFox — An instance of the SmartFoxServer 2X client API main SmartFox class.

See also

Method Detail
containsBuddy()method
public function containsBuddy(name:String):Boolean

Indicates whether a buddy exists in user's buddies list or not.

Parameters

name:String — The name of the buddy whose presence in the buddies list is to be tested.

Returns
Booleantrue if the specified buddy exists in the buddies list.
getBuddyById()method 
public function getBuddyById(id:int):Buddy

Retrieves a Buddy object from its id property.

Parameters

id:int — The id of the buddy to be found.

Returns
Buddy — The Buddy object representing the buddy, or null if no buddy with the passed id exists in the buddies list.
getBuddyByName()method 
public function getBuddyByName(name:String):Buddy

Retrieves a Buddy object from its name property.

Parameters

name:String — The name of the buddy to be found.

Returns
Buddy — The Buddy object representing the buddy, or null if no buddy with the passed name exists in the buddies list.
getBuddyByNickName()method 
public function getBuddyByNickName(nickName:String):Buddy

Retrieves a Buddy object from its nickName property (if set).

Parameters

nickName:String — The nickName of the buddy to be found.

Returns
Buddy — The Buddy object representing the buddy, or null if no buddy with the passed nickName exists in the buddies list.
getMyVariable()method 
public function getMyVariable(varName:String):BuddyVariable

Retrieves a Buddy Variable from its name.

Parameters

varName:String — The name of the Buddy Variable to be retrieved.

Returns
BuddyVariable — The BuddyVariable object representing the Buddy Variable, or null if no Buddy Variable with the passed name is associated with the current user.