Class AddBuddyRequest

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

    public class AddBuddyRequest
    extends BaseRequest
    Adds a new buddy to the current user's buddies list.

    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
    The following example sends a request to add a buddy:

     private void someMethod() {
         sfs.addEventListener(SFSBuddyEvent.BUDDY_ADD, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 System.out.println("This buddy was added:" + ((Buddy)evt.getArguments().get("buddy")).getName());
             }
         });
         
         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"));
             }
         });
         
         // Add Jack as a new buddy to my buddies list
         sfs.send(new AddBuddyRequest("Jack"));
     }
     
    See Also:
    SFSBuddyEvent.BUDDY_ADD, SFSBuddyEvent.BUDDY_ERROR, RemoveBuddyRequest, InitBuddyListRequest
    • Field Detail

      • KEY_BUDDY_NAME

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

      • AddBuddyRequest

        public AddBuddyRequest​(java.lang.String buddyName)
        Creates a new AddBuddyRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
        Parameters:
        buddyName - The name of the user to be added as a buddy.
        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 *