| Package | com.electrotank.electroserver4 |
| Class | public class ElectroServer |
| Inheritance | ElectroServer Observable |
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new ElectroServer class instance.
| ElectroServer | ||
|
Adds a user to the client's buddy list.
| ElectroServer | ||
![]() |
addEventListener(mt:MessageType, funcName:String, scope:Object, first:Boolean = false):void
| Observable | |
![]() |
addListener(ob:Object):void
| Observable | |
|
close():void
Closes all open connections with ElectroServer
| ElectroServer | ||
|
closeRtmpConnection():void
Closes the RtmpConnection.
| ElectroServer | ||
|
createConnection(ip:String, port:Number):Connection
Creates a new Connection instance and returns it.
| ElectroServer | ||
|
createHttpConnection(ip:String, port:Number):HttpConnection
Creates a new HttpConnection instance and returns it.
| ElectroServer | ||
|
createRtmpConnection(ip:String, port:Number):RtmpConnection
Creates a new RtmpConnection with ElectroServer.
| ElectroServer | ||
![]() |
dispatchEvent(eventOb:MessageImpl):void
| Observable | |
|
getBuddyList():Object
Returns an Object of of buddies stored by user name.
| ElectroServer | ||
|
getConnections():Array
Gets the list of open connections.
| ElectroServer | ||
|
getDebug():Boolean
Gets the debug status and returns it as a Boolean value.
| ElectroServer | ||
|
getIsLoggedIn():Boolean
Returns true if the client is logged in and false if not logged in.
| ElectroServer | ||
|
getProtocol():String
Gets the protocol being used.
| ElectroServer | ||
|
Returns the RtmpConnection.
| ElectroServer | ||
|
Returns the UserManager instance.
| ElectroServer | ||
|
Returns the ZoneManager.
| ElectroServer | ||
![]() |
notifyListeners(eventName:String, eventOb:Object):void
| Observable | |
|
onBinaryData(ev:Object):void
| ElectroServer | ||
|
removeBuddy(name:String):void
Removes a buddy from the buddy list.
| ElectroServer | ||
![]() |
removeEventListener(mt:MessageType, funcName:String, scope:Object):void
| Observable | |
![]() |
removeListener(ob:Object):void
| Observable | |
|
Sends a request or response object to the server.
| ElectroServer | ||
|
setDebug(debug:Boolean):void
This method is used to toggle all message taffic from being traced in the output console.
| ElectroServer | ||
|
setProtocol(protocol:String):void
Sets the protocol.
| ElectroServer | ||
|
startSimulatingLatency(latency:Number):void
This method starts a latency simulation.
| ElectroServer | ||
|
stopSimulatingLatency():void
Stops the latency simulation.
| ElectroServer | ||
| ElectroServer | () | constructor |
public function ElectroServer()Creates a new ElectroServer class instance.
| addBuddy | () | method |
public function addBuddy(name:String, esob:EsObject):voidAdds a user to the client's buddy list. The list is maintained by the server. Buddy online/offline status updates are sent to the client.
Parametersname:String — name The buddy's user name.
|
|
esob:EsObject — esob An EsObject to store with the buddy entry.
|
See also
| close | () | method |
public function close():voidCloses all open connections with ElectroServer
See also
| closeRtmpConnection | () | method |
public function closeRtmpConnection():voidCloses the RtmpConnection.
See also
import com.electrotank.electroserver4.ElectroServer;
var es:ElectroServer;//created and connected somewhere else
es.closeRtmpConnection();
| createConnection | () | method |
public function createConnection(ip:String, port:Number):ConnectionCreates a new Connection instance and returns it. Internally a new XMLSocket (string protocol) or Socket (AS3 binary) is created and used to communicate with the server via text or binary protocol.
Parametersip:String |
|
port:Number |
Connection |
See also
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.connection;
import com.electrotank.electroserver4.message.MessageType;
import com.electrotank.electroserver4.message.event.
//
var es:ElectroServer = new ElectroServer();
es.addEventListener(MessageType.ConnectionEvent, "onConnectionEvent", this);
public function onConnectionEvent(e:ConnectionEvent):void {
if (e.getAccepted()) {
//connection accepted
} else {
//connection failed
}
}
| createHttpConnection | () | method |
public function createHttpConnection(ip:String, port:Number):HttpConnectionCreates a new HttpConnection instance and returns it. Internally a new URLLoader/URLRequest is created and used to communicate with the server via binary protocol.
Parametersip:String |
|
port:Number |
HttpConnection |
See also
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.connection;
import com.electrotank.electroserver4.message.MessageType;
import com.electrotank.electroserver4.message.event.
//
var es:ElectroServer = new ElectroServer();
es.addEventListener(MessageType.ConnectionEvent, "onConnectionEvent", this);
public function onConnectionEvent(e:ConnectionEvent):void {
if (e.getAccepted()) {
//connection accepted
} else {
//connection failed
}
}
| createRtmpConnection | () | method |
public function createRtmpConnection(ip:String, port:Number):RtmpConnectionCreates a new RtmpConnection with ElectroServer. RtmpConnection is used to create new NetStream instances that are used to publish or subscribe to audio and video streams. RtmpConnection internally creates a NetConnection class instance to manage its connection with ElectroServer using the Flash player's built-in RTMP support.
Parametersip:String |
|
port:Number |
RtmpConnection —
RtmpConnection
|
See also
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.message.MessageType;
import com.electrotank.electroserver4.message.event.RtmpConnectionEvent;
var es:ElectroServer;
var ip:String = "127.0.0.1";
var port:Number = 1935;
es.addEventListener(MessageType.RtmpConnectionEvent, "onRtmpConnection", this);
es.createRtmpConnection(ip, port);
public function onRtmpConnection(e:RtmpConnectionEvent):void {
if (e.getAccepted()) {
//connection accepted
} else {
//connecton failed
}
}
| getBuddyList | () | method |
public function getBuddyList():ObjectReturns an Object of of buddies stored by user name.
ReturnsObject — Object containing buddies by user name.
|
See also
| getConnections | () | method |
public function getConnections():ArrayGets the list of open connections.
ReturnsArray — Array of connections. Each element is of type Connection
|
| getDebug | () | method |
public function getDebug():BooleanGets the debug status and returns it as a Boolean value. If debugging is turned on then message traffic is traced to the output window in the Flash IDE and logged.
ReturnsBoolean — The debug status as a Boolean.
|
See also
| getIsLoggedIn | () | method |
public function getIsLoggedIn():BooleanReturns true if the client is logged in and false if not logged in.
ReturnsBoolean |
import com.electrotank.electroserver4.ElectroServer;
var es:ElectroServer;//created and connected somewhere else
var isLoggedIn:Boolean = es.getIsLoggedIn();
| getProtocol | () | method |
public function getProtocol():StringGets the protocol being used.
ReturnsString — The protocol being used.
|
| getRtmpConnection | () | method |
public function getRtmpConnection():RtmpConnectionReturns the RtmpConnection.
ReturnsRtmpConnection —
RtmpConnection
|
See also
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.rtmpconnection.RtmpConnection;
//
var es:ElectroServer;//created and already connected somewhere else
var rtmpConnection:RtmpConnection = es.getRtmpConnection();
| getUserManager | () | method |
public function getUserManager():UserManagerReturns the UserManager instance. The UserManager is used to keep track of users that you should be able to see. If you see a user in multiple rooms it points back to the same User instance.
ReturnsUserManager —
Returns the UserManager
|
See also
| getZoneManager | () | method |
public function getZoneManager():ZoneManagerReturns the ZoneManager. One instance of ZoneManager exists and keeps track of the zones.
ReturnsZoneManager —
Returns the ZoneManager instance.
|
See also
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.connection;
import com.electrotank.electroserver4.message.MessageType;
import com.electrotank.electroserver4.message.event.
//
var es:ElectroServer;//created and connected somewhere else
var zm:ZoneManager = es.getZoneManager();
var rooms:Array = zm.getZone("Lobby Zone").getRooms();
for (var i:Number=0;i| onBinaryData | () | method |
public function onBinaryData(ev:Object):voidParameters
ev:Object |
| removeBuddy | () | method |
public function removeBuddy(name:String):voidRemoves a buddy from the buddy list.
Parametersname:String — The user name of the buddy to remove.
|
See also
| send | () | method |
public function send(message:Message):SendStatusSends a request or response object to the server. A client can only communicate with the server via this method and via RtmpConnection.
Parametersmessage:Message — The request object to send to the server. This is one of the most commonly used methods of the ElectroServer class. First you build a request object and populate it with information (such as LoginRequest), and then you send it using this method. The message is first validated before the API sends it. If the messages fails validation then SendStatus.getIsSent() returns false.
|
SendStatus —
Returns a SendStatus object which contains information saying if the message passed validation and was sent, or not.
|
See also
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.message.request.LoginRequest;
import com.electrotank.electroserver4.message.response.LoginResponse;
import com.electrotank.electroserver4.message.MessageType;
//Build a request, send it, capture the response
var lr:LoginRequest = new LoginRequest();
lr.setUserName("McLovin");
es.send(lr);
//
public function onLoginResponse(e:LoginResponse):void {
if (e.getAccepted()) {
//login accepted
} else {
//login failed
}
}
| setDebug | () | method |
public function setDebug(debug:Boolean):voidThis method is used to toggle all message taffic from being traced in the output console. Pass in true or false to enable or disable log messages getting traced to the output window in the Flash IDE. If debugging is on then all message traffic is traced to the output window when the onLog event is called. You can listen for log events directly by using the Logger class.
Parametersdebug:Boolean — True or false to enable/disable log messages tracing to the output window.
|
See also
| setProtocol | () | method |
public function setProtocol(protocol:String):voidSets the protocol. The default is Protocol.TEXT. Valid options are Protocol.TEXT and Protocol.BINARARY (AS3 and above).
Parametersprotocol:String — The protocol to use.
|
| startSimulatingLatency | () | method |
public function startSimulatingLatency(latency:Number):voidThis method starts a latency simulation. The actual latency simulated will be the real latency of this client plus the value passed in here.
Parameterslatency:Number — The latency to simulate.
|
| stopSimulatingLatency | () | method |
public function stopSimulatingLatency():voidStops the latency simulation.