Class BlockBuddyRequest

  • All Implemented Interfaces:
    sfs2x.client.requests.IRequest

    public class BlockBuddyRequest
    extends BaseRequest
    Blocks or unblocks a buddy in the current user's buddies list. Blocked buddies won't be able to see if the user who blocked them is online in their buddies 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).

    Example
    The following example sends a request to block a buddy:

     private void someMethod() {
         sfs.addEventListener(SFSBuddyEvent.BUDDY_BLOCK, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 boolean isBlocked = ((Buddy)evt.getArguments().get("buddy")).isBlocked();
                 System.out.println("Buddy " + ((Buddy)evt.getArguments().get("buddy")).getName() + " is now " + (isBlocked ? "blocked" : "unblocked"));
             }
         });
         
         sfs.addEventListener(SFSBuddyEvent.BUDDY_ERROR, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 System.out.println("The following error occurred while executing a buddy-related request:" + (String)evt.getArguments().get("errorMessage"));
             }
         });
         
         // Block Jack in my buddies list
         sfs.send(new BlockBuddyRequest("Jack", true));
     }
     
    See Also:
    SFSBuddyEvent.BUDDY_BLOCK, SFSBuddyEvent.BUDDY_ERROR, InitBuddyListRequest
    • Field Detail

      • KEY_BUDDY_NAME

        public static final java.lang.String KEY_BUDDY_NAME
        * API internal usage only *
        See Also:
        Constant Field Values
      • KEY_BUDDY

        public static final java.lang.String KEY_BUDDY
        * API internal usage only *
        See Also:
        Constant Field Values
      • KEY_BUDDY_BLOCK_STATE

        public static final java.lang.String KEY_BUDDY_BLOCK_STATE
        * API internal usage only *
        See Also:
        Constant Field Values
    • Constructor Detail

      • BlockBuddyRequest

        public BlockBuddyRequest​(java.lang.String buddyName,
                                 boolean blocked)
        Creates a new BlockBuddyRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
        Parameters:
        buddyName - The name of the buddy to be blocked or unblocked.
        blocked - true if the buddy must be blocked; false if he must be unblocked.
        See Also:
        SmartFox.send(sfs2x.client.requests.IRequest)
    • Method Detail

      • validate

        public void validate​(ISmartFox sfs)
                      throws sfs2x.client.exceptions.SFSValidationException
        * API internal usage only *
        Throws:
        sfs2x.client.exceptions.SFSValidationException
      • execute

        public void execute​(ISmartFox sfs)
        * API internal usage only *