com.electrotank.electroserver5.client.api
Class EsConnectionAttemptResponse

java.lang.Object
  extended by com.electrotank.electroserver5.client.events.Event<EsMessageType>
      extended by com.electrotank.electroserver5.client.api.helper.EsMessage
          extended by com.electrotank.electroserver5.client.api.helper.EsResponse
              extended by com.electrotank.electroserver5.client.api.EsConnectionAttemptResponse
All Implemented Interfaces:
ThriftSerializable

public class EsConnectionAttemptResponse
extends EsResponse

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

EsConnectionAttemptResponse

public EsConnectionAttemptResponse()

EsConnectionAttemptResponse

public EsConnectionAttemptResponse(org.apache.thrift.TBase t)
Method Detail

toThrift

public com.electrotank.electroserver5.thrift.ThriftConnectionAttemptResponse toThrift()

newThrift

public com.electrotank.electroserver5.thrift.ThriftConnectionAttemptResponse newThrift()

fromThrift

public void fromThrift(org.apache.thrift.TBase t_)

isSuccessful

public boolean isSuccessful()
True if this connection attempt succeeded, false if it failed. If false then inspect the error property for a reason.


setSuccessful

public void setSuccessful(boolean v)
True if this connection attempt succeeded, false if it failed. If false then inspect the error property for a reason.


getConnectionId

public int getConnectionId()
Local id of the connection this event describes.


setConnectionId

public void setConnectionId(int v)
Local id of the connection this event describes.


getError

public EsErrorType getError()
If successful == false this property is non-null and contains a reason for the connection failure.


setError

public void setError(EsErrorType v)
If successful == false this property is non-null and contains a reason for the connection failure.



Copyright © 2007-2010 Electrotank, Inc. All Rights Reserved.