Packagecom.electrotank.electroserver4.message.request
Classpublic class AddBuddyRequest
InheritanceAddBuddyRequest Inheritance com.electrotank.electroserver4.message.request.RequestImpl

Use the ElectroServer.addBuddy method to add a new buddy. The AddBuddyRequest is used by the ElectroServer class to add the buddy with ElectroServer. You use the ElectroServer.addBuddy method because buddies are managed on the client as well as the server. When a buddy logs in or leaves the server a BuddyStatusUpdatedEvent is fired off to you.


Example
Shows how to add a buddy and listen for BuddyStatusUpdatedEvents.
    //import the needed classes
    import com.electrotank.electroserver4.ElectroServer;
    import com.electrotank.electroserver4.esobject.EsObject;
    import com.electrotank.electroserver4.message.event.BuddyStatusUpdatedEvent;
    import com.electrotank.electroserver4.message.MessageType;
    //
    //Add the buddy
    var es:ElectroServer;//It is assumed that this refers to an ElectroServer class instance that is connected to ElectroServer
    es.addBuddy("crazy_face", new EsObject());
    //
    //Configure the event listener to know when your buddy's online status changes
    es.addEventListener(MessageType.BuddyStatusUpdatedEvent, "onBuddyStatusUpdatedEvent", this);
    public function onBuddyStatusUpdatedEvent(e:BuddyStatusUpdatedEvent):void {
        var u:User = e.getUser();
        switch(e.getActionId()) {
            case BuddyStatusUpdatedEvent.LoggedIn:
                trace(u.getUserName()+" logged in.");
                break;
            case BuddyStatusUpdatedEvent.LoggedOut:
                trace(u.getUserName()+" logged out.");
                break;
            default:
                trace("Update event not handled.");
                break;
        }
    }
                

See also

com.electrotank.electroserver4.ElectroServer.addBuddy()
com.electrotank.electroserver4.message.event.BuddyStatusUpdatedEvent


Public Methods
 MethodDefined by
  
Creates a new instance of the AddBuddyRequest
AddBuddyRequest
  
getBuddyName():String
Gets the buddy name.
AddBuddyRequest
  
Gets the optional EsObject associated with the buddy in this request.
AddBuddyRequest
  
setBuddyName(name:String):void
Sets the name of the buddy.
AddBuddyRequest
  
setEsObject(esob:EsObject):void
This associates an optional EsObject with your buddy.
AddBuddyRequest
  
AddBuddyRequest
Constructor detail
AddBuddyRequest()constructor
public function AddBuddyRequest()

Creates a new instance of the AddBuddyRequest

Method detail
getBuddyName()method
public function getBuddyName():String

Gets the buddy name.

Returns
String — Returns the buddy name.
getEsObject()method 
public function getEsObject():EsObject

Gets the optional EsObject associated with the buddy in this request.

Returns
EsObject — EsObject associated with the buddy.
setBuddyName()method 
public function setBuddyName(name:String):void

Sets the name of the buddy. When a user logs in (or out) with this user name a BuddyStatusUpdatedEvent is fired.

Parameters
name:String — name
setEsObject()method 
public function setEsObject(esob:EsObject):void

This associates an optional EsObject with your buddy. Event handlers on the server can use this EsObject to perform custom logic to make more intricate buddy behaviors.

Parameters
esob:EsObject — esob EsObject to be associated with your buddy.
validate()method 
public override function validate():ValidationResponse

Returns
ValidationResponse