Class SFS2X.Requests.BuddyList.BlockBuddyRequest

Blocks or unblocks a buddy in the current user's buddy list.

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

Class Detail

SFS2X.Requests.BuddyList.BlockBuddyRequest(buddyName, blocked)
Creates a new BlockBuddyRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Blocked buddies won't be able to see if the user who blocked them is online in their buddy list; they also won't be able to send messages or requests to that user.

In order to block a buddy, the current user must be online in the Buddy List system. If the operation is successful, a buddyBlock confirmation event is dispatched; 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 handles the possible events caused by a request to block a buddy:

function someMethod()
	sfs.addEventListener(SFS2X.SFSBuddyEvent.BUDDY_BLOCK, onBuddyBlock, this);
	sfs.addEventListener(SFS2X.SFSBuddyEvent.BUDDY_ERROR, onBuddyError, this);
	// Block user "Jack" in my buddies list
	smartFox.send(new SFS2X.Requests.BuddyList.BlockBuddyRequest("Jack", true));

function onBuddyBlock(evtParams)
	var isBlocked = evtParams.buddy.isBlocked();
	console.log("Buddy " + + " is now " + (isBlocked ? "blocked" : "unblocked"));

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