new AddBuddyRequest(buddyName)

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

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).

Example

This 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.AddBuddyRequest("Jack"));
}

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

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

Parameter

Name Type Optional Description

buddyName

 

 

The name of the user to be added as a buddy.

See also
SmartFox#send
SFSBuddyEvent.BUDDY_ADD
SFSBuddyEvent.BUDDY_ERROR
RemoveBuddyRequest