|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.electrotank.electroserver5.client.events.Event<EsMessageType>
com.electrotank.electroserver5.client.api.helper.EsMessage
com.electrotank.electroserver5.client.api.helper.EsResponse
com.electrotank.electroserver5.client.api.EsConnectionAttemptResponse
public class EsConnectionAttemptResponse
Before a client can do anything with the server a connection must be established. When connectinghave the ability to specify a series of connections to attempt. They are attempted in order until one succeeds or they all fail. As each connection individually succeeds or fails a ConnectionAttemptResponse event is fired off. Once a connection succeeds or they all fail, a ConnectionResponse event is fired off.
package {
import flash.display.Sprite;
import flash.events.Event;
//ElectroServer imports
import com.electrotank.electroserver5.api.ConnectionAttemptResponse;
import com.electrotank.electroserver5.api.ConnectionResponse;
import com.electrotank.electroserver5.api.MessageType;
import com.electrotank.electroserver5.ElectroServer;
//Logger imports
import mx.logging.Log;
import mx.logging.targets.TraceTarget;
public class Main extends Sprite {
private var _es:ElectroServer = new ElectroServer();
public function Main():void {
//add this so we can see the logs get traced
Log.addTarget(new TraceTarget());
//load settings file and connect
_es.loadAndConnect("settings.xml");
//listen to key events to know when a connection has succeeded or failed
_es.engine.addEventListener(MessageType.ConnectionResponse.name, onConnectionResponse);
_es.engine.addEventListener(MessageType.ConnectionAttemptResponse.name, onConnectionAttemptResponse);
}
private function onConnectionAttemptResponse(e:ConnectionAttemptResponse):void {
trace("Connection attempt success: " + e.successful.toString());
if (!e.successful) {
trace(e.error.name);
}
}
private function onConnectionResponse(e:ConnectionResponse):void {
trace("Connection success: " + e.successful.toString());
if (!e.successful) {
trace(e.error.name);
}
}
}
}
| Constructor Summary | |
|---|---|
EsConnectionAttemptResponse()
|
|
EsConnectionAttemptResponse(org.apache.thrift.TBase t)
|
|
| Method Summary | |
|---|---|
void |
fromThrift(org.apache.thrift.TBase t_)
|
int |
getConnectionId()
Local id of the connection this event describes. |
EsErrorType |
getError()
If successful == false this property is non-null and contains a reason for the connection failure. |
boolean |
isSuccessful()
True if this connection attempt succeeded, false if it failed. |
com.electrotank.electroserver5.thrift.ThriftConnectionAttemptResponse |
newThrift()
|
void |
setConnectionId(int v)
Local id of the connection this event describes. |
void |
setError(EsErrorType v)
If successful == false this property is non-null and contains a reason for the connection failure. |
void |
setSuccessful(boolean v)
True if this connection attempt succeeded, false if it failed. |
com.electrotank.electroserver5.thrift.ThriftConnectionAttemptResponse |
toThrift()
|
| Methods inherited from class com.electrotank.electroserver5.client.api.helper.EsMessage |
|---|
getMessageNumber, getMessageType, getRequestId, getServerId, setMessageNumber, setMessageType, setRequestId, setServerId |
| Methods inherited from class com.electrotank.electroserver5.client.events.Event |
|---|
getType, setType |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EsConnectionAttemptResponse()
public EsConnectionAttemptResponse(org.apache.thrift.TBase t)
| Method Detail |
|---|
public com.electrotank.electroserver5.thrift.ThriftConnectionAttemptResponse toThrift()
public com.electrotank.electroserver5.thrift.ThriftConnectionAttemptResponse newThrift()
public void fromThrift(org.apache.thrift.TBase t_)
public boolean isSuccessful()
public void setSuccessful(boolean v)
public int getConnectionId()
public void setConnectionId(int v)
public EsErrorType getError()
public void setError(EsErrorType v)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||