Class SFS2X.Requests.BuddyList.InitBuddyListRequest

Initializes the Buddy List system on the current client.

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

Class Detail

Creates a new InitBuddyListRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Buddy List system initialization involves loading any previously stored buddy-specific data from the server, such as the current user's buddy list, his previous state and the persistent Buddy Variables. The initialization request is the first operation to be executed in order to be able to use the Buddy List system features. Once the initialization is completed, the buddyListInit event id fired and the user has access to all his data set previously and he can start to interact with his buddies; if the initialization fails, a buddyError event is fired.

The following example initializes the Buddy List system:

function someMethod()
	sfs.addEventListener(SFS2X.SFSBuddyEvent.BUDDY_LIST_INIT, onBuddyListInitialized, this);
	sfs.addEventListener(SFS2X.SFSBuddyEvent.BUDDY_ERROR, onBuddyError, this)
	// Initialize the Buddy List system
	sfs.send(new SFS2X.Requests.BuddyList.InitBuddyListRequest());

function onBuddyListInitialized(evtParams)
	console.log("Buddy List system initialized successfully");
	// Retrieve my buddies list
	var buddies = sfs.buddyManager.getBuddyList();
	// Display the online buddies in a list component in the application interface

function onBuddyError(evtParams)
	console.log("The following error occurred while executing a buddy-related request: " + evtParams.errorMessage);
See also: