Packagecom.smartfoxserver.v2.requests.buddylist
Classpublic class AddBuddyRequest
InheritanceAddBuddyRequest Inheritance com.smartfoxserver.v2.requests.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).

View the examples

See also

buddyAdd event
buddyError event
RemoveBuddyRequest
InitBuddyListRequest


Public Methods
 MethodDefined By
  
AddBuddyRequest(buddyName:String)
Creates a new AddBuddyRequest instance.
AddBuddyRequest
Constructor Detail
AddBuddyRequest()Constructor
public function AddBuddyRequest(buddyName:String)

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

Parameters
buddyName:String — The name of the user to be added as a buddy.

See also

Examples
The following example sends a request to add a buddy:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSBuddyEvent.BUDDY_ADD, onBuddyAdded);
         sfs.addEventListener(SFSBuddyEvent.BUDDY_ERROR, onBuddyError);
         
         // Add Jack as a new buddy to my buddies list
         sfs.send(new AddBuddyRequest("Jack"));
     }
     
     private function onBuddyAdded(evt:SFSBuddyEvent):void
     {
         trace("This buddy was added:", evt.params.buddy.name);
     }
     
     private function onBuddyError(evt:SFSBuddyEvent):void
     {
         trace("The following error occurred while executing a buddy-related request:", evt.params.errorMessage);
     }