Packagecom.smartfoxserver.v2.requests.buddylist
Classpublic class BlockBuddyRequest
InheritanceBlockBuddyRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

Blocks or unblocks a buddy in the current user's buddies list. Blocked buddies 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).

View the examples

See also

buddyBlock event
buddyError event
InitBuddyListRequest


Public Methods
 MethodDefined By
  
BlockBuddyRequest(buddyName:String, blocked:Boolean)
Creates a new BlockBuddyRequest instance.
BlockBuddyRequest
Constructor Detail
BlockBuddyRequest()Constructor
public function BlockBuddyRequest(buddyName:String, blocked:Boolean)

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

Parameters
buddyName:String — The name of the buddy to be blocked or unblocked.
 
blocked:Booleantrue if the buddy must be blocked; false if he must be unblocked.

See also

Examples
The following example sends a request to block a buddy:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSBuddyEvent.BUDDY_BLOCK, onBuddyBlock);
         sfs.addEventListener(SFSBuddyEvent.BUDDY_ERROR, onBuddyError);
         
         // Block Jack in my buddies list
         sfs.send(new BlockBuddyRequest("Jack", true));
     }
     
     private function onBuddyBlock(evt:SFSBuddyEvent):void
     {
         var isBlocked:Boolean = evt.params.buddy.isBlocked;
         trace("Buddy " + evt.params.buddy.name + " is now " + (isBlocked ? "blocked" : "unblocked"));
     }
     
     private function onBuddyError(evt:SFSBuddyEvent):void
     {
         trace("The following error occurred while executing a buddy-related request:", evt.params.errorMessage);
     }