Class SFS2X.Requests.BuddyList.AddBuddyRequest

Adds a new buddy to the current user's buddy list.

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

Class Detail

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

In order to add a buddy, the current user must be online in the Buddy List system. If the buddy is added successfully, the operation is confirmed by a buddyAdd event; otherwise the buddyError event is fired.

NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).

The following example sends a request to add a buddy:

function someMethod()
	sfs.addEventListener(SFS2X.SFSBuddyEvent.BUDDY_ADD, onBuddyAdded, this);
	sfs.addEventListener(SFS2X.SFSBuddyEvent.BUDDY_ERROR, onBuddyError, this);
	// Add Jack as a new buddy to my buddies list
	sfs.send(new SFS2X.Requests.BuddyList.AddBuddyRequest("Jack"));

function onBuddyAdded(evtParams)
	console.log("This buddy was added: " +;

function onBuddyError(evtParams)
	console.log("The following error occurred while executing a buddy-related request: " + evtParams.errorMessage);
{String} buddyName
The name of the user to be added as a buddy.
See also: