SFSBuddyManager
The manager of the current user's Buddy List system.
Property
new SFSBuddyManager()
Developers never istantiate the SFSBuddyManager class: this is done internally by the SmartFoxServer 2X API; get a reference to it using the SmartFox.buddyManager property.
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.
Property
isInited boolean
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.
- See also
- InitBuddyListRequest
Methods
containsBuddy(name) → boolean
Indicates whether a buddy exists in user's buddy list or not.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
name |
string |
|
The name of the buddy whose presence in the buddy list is to be checked. |
- See also
- SFSBuddy#name
- Returns
-
boolean
true
if the specified buddy exists in the buddy list.
getBuddyById(id) → SFSBuddy
Retrieves a SFSBuddy object from its id property.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
id |
number |
|
The id of the buddy to be retrieved. |
- See also
- SFSBuddy#id
- Returns
-
SFSBuddy
The SFSBuddy object representing the buddy, orundefined
if no buddy with the passed id exists in the buddy list.
getBuddyByName(name) → SFSBuddy
Retrieves a SFSBuddy object from its name property.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
name |
string |
|
The name of the buddy to be retrieved. |
- See also
- SFSBuddy#name
- Returns
-
SFSBuddy
The SFSBuddy object representing the buddy, orundefined
if no buddy with the passed name exists in the buddy list.
getBuddyByNickName(nickName) → SFSBuddy
Retrieves a SFSBuddy object using its nickName property.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
nickName |
string |
|
The nickname of the buddy to be found. |
- See also
- SFSBuddy#nickName
- Returns
-
SFSBuddy
The SFSBuddy object representing the buddy, orundefined
if no buddy with the passed nickname exists in the buddies list.
getBuddyList() → Array of SFSBuddy
Returns a list of SFSBuddy objects representing all the buddies in the user's buddy list.
- See also
- InitBuddyListRequest
- Returns
-
Array of SFSBuddy
A list of SFSBuddy objects representing all the buddies.
getBuddyStates() → Array of string
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.
- See also
- SFSBuddy#getState
- Returns
-
Array of string
The list of available custom buddy states in the Buddy List system.
getMyNickName() → string
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.
- See also
- SFSBuddy#getNickName
- ReservedBuddyVariables
- SetBuddyVariablesRequest
- Returns
-
string
The user nickname in the Buddy List system.
getMyOnlineState() → boolean
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.
- See also
- SFSBuddy#isOnline
- ReservedBuddyVariables
- GoOnlineRequest
- Returns
-
boolean
true
if the user is online in the Buddy List system.
getMyState() → string
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.
- See also
- SFSBuddy#getState
- ReservedBuddyVariables
- SetBuddyVariablesRequest
- Returns
-
string
The user state in the Buddy List system.
getMyVariable(varName) → SFSBuddyVariable
Retrieves a Buddy Variable set for the current user from its name.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
varName |
string |
|
The name of the Buddy Variable to be retrieved. |
- See also
- SetBuddyVariablesRequest
- Returns
-
SFSBuddyVariable
The SFSBuddyVariable object representing the Buddy Variable, orundefined
if no Buddy Variable with the passed name is associated to the current user.
getMyVariables() → Array of SFSBuddyVariable
Returns all the Buddy Variables set for the current user.
- See also
- SFSBuddyVariable
- Returns
-
Array of SFSBuddyVariable
A list of SFSBuddyVariable objects representing all the Buddy Variables set for the user.
getOfflineBuddies() → Array of SFSBuddy
Returns a list of SFSBuddy objects representing all the offline buddies in the user's buddy list.
- See also
- SFSBuddy#isOnline
- Returns
-
Array of SFSBuddy
A list of SFSBuddy objects representing the offline buddies.
getOnlineBuddies() → Array of SFSBuddy
Returns a list of SFSBuddy objects representing all the online buddies in the user's buddy list.
- See also
- SFSBuddy#isOnline
- Returns
-
Array of SFSBuddy
A list of SFSBuddy objects representing the online buddies.