| Package | com.smartfoxserver.v2.requests.buddylist |
| Class | public class AddBuddyRequest |
| Inheritance | AddBuddyRequest com.smartfoxserver.v2.requests.BaseRequest |
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).
See also
| Method | Defined By | ||
|---|---|---|---|
AddBuddyRequest(buddyName:String)
Creates a new AddBuddyRequest instance. | AddBuddyRequest | ||
| 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.
ParametersbuddyName:String — The name of the user to be added as a buddy.
|
See also
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);
}