ElectroServer 5 Client: C#
Electrotank.Electroserver5.Api.ConnectionAttemptResponse Class Reference

Before a client can do anything with the server a connection must be established. More...

Inheritance diagram for Electrotank.Electroserver5.Api.ConnectionAttemptResponse:
Electrotank.Electroserver5.Api.EsResponse Electrotank.Electroserver5.Api.EsMessage Electrotank.Electroserver5.Api.IThriftSerializable

Public Member Functions

 ConnectionAttemptResponse ()
 
 ConnectionAttemptResponse (TBase t)
 
override TBase ToThrift ()
 
override TBase NewThrift ()
 
override void FromThrift (TBase t_)
 
- Public Member Functions inherited from Electrotank.Electroserver5.Api.EsResponse
 EsResponse ()
 

Properties

bool Successful [get, set]
 True if this connection attempt succeeded, false if it failed. More...
 
int ConnectionId [get, set]
 Local id of the connection this event describes. More...
 
ErrorType Error [get, set]
 If successful == false this property is non-null and contains a reason for the connection failure. More...
 

Detailed Description

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 & Destructor Documentation

Electrotank.Electroserver5.Api.ConnectionAttemptResponse.ConnectionAttemptResponse ( )
Electrotank.Electroserver5.Api.ConnectionAttemptResponse.ConnectionAttemptResponse ( TBase  t)

Member Function Documentation

override void Electrotank.Electroserver5.Api.ConnectionAttemptResponse.FromThrift ( TBase  t_)
virtual
override TBase Electrotank.Electroserver5.Api.ConnectionAttemptResponse.NewThrift ( )
virtual
override TBase Electrotank.Electroserver5.Api.ConnectionAttemptResponse.ToThrift ( )
virtual

Property Documentation

int Electrotank.Electroserver5.Api.ConnectionAttemptResponse.ConnectionId
getset

Local id of the connection this event describes.

ErrorType Electrotank.Electroserver5.Api.ConnectionAttemptResponse.Error
getset

If successful == false this property is non-null and contains a reason for the connection failure.

bool Electrotank.Electroserver5.Api.ConnectionAttemptResponse.Successful
getset

True if this connection attempt succeeded, false if it failed.

If false then inspect the error property for a reason.