| Package | com.electrotank.electroserver4.message.request |
| Class | public class AddBuddyRequest |
| Inheritance | AddBuddyRequest com.electrotank.electroserver4.message.request.RequestImpl |
//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
| Method | Defined 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 | |||
| AddBuddyRequest | () | constructor |
public function AddBuddyRequest()Creates a new instance of the AddBuddyRequest
| getBuddyName | () | method |
public function getBuddyName():StringGets the buddy name.
ReturnsString — Returns the buddy name.
|
| getEsObject | () | method |
public function getEsObject():EsObjectGets the optional EsObject associated with the buddy in this request.
ReturnsEsObject —
EsObject associated with the buddy.
|
| setBuddyName | () | method |
public function setBuddyName(name:String):voidSets the name of the buddy. When a user logs in (or out) with this user name a BuddyStatusUpdatedEvent is fired.
Parametersname:String — name
|
| setEsObject | () | method |
public function setEsObject(esob:EsObject):voidThis 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.
Parametersesob:EsObject — esob EsObject to be associated with your buddy.
|
| validate | () | method |