If we never dispatched a DID_LOGON, then don't dispatch a DID_LOGOFF. Dispatch
a FAILED_TO_LOGON instead. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5688 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -30,8 +30,7 @@ public class ClientEvent extends Event
|
||||
public static const CLIENT_FAILED_TO_LOGON :String = "clientFailedLogon";
|
||||
public static const CLIENT_OBJECT_CHANGED :String = "clobjChanged";
|
||||
public static const CLIENT_CONNECTION_FAILED :String = "clientConnFailed";
|
||||
/** The logoff itself can be cancelled if a listener calls
|
||||
* preventDefault() on this event. */
|
||||
/** The logoff itself can be cancelled if a listener calls preventDefault() on this event. */
|
||||
public static const CLIENT_WILL_LOGOFF :String = "clientWillLogoff";
|
||||
public static const CLIENT_DID_LOGOFF :String = "clientDidLogoff";
|
||||
public static const CLIENT_DID_CLEAR :String = "clientDidClear";
|
||||
|
||||
@@ -152,7 +152,12 @@ public class Communicator
|
||||
_writer = null;
|
||||
}
|
||||
|
||||
_client.notifyObservers(ClientEvent.CLIENT_DID_LOGOFF, null);
|
||||
// if we never got our client object, we never dispatched a DID_LOGON and therefore we
|
||||
// don't want to dispatch a DID_LOGOFF, the observers basically never know anything ever
|
||||
// happened
|
||||
if (_client.getClientObject() != null) {
|
||||
_client.notifyObservers(ClientEvent.CLIENT_DID_LOGOFF, null);
|
||||
}
|
||||
_client.cleanup(logonError);
|
||||
}
|
||||
|
||||
@@ -306,7 +311,7 @@ public class Communicator
|
||||
// total failure
|
||||
log.warning("Socket error: " + event, "target", event.target);
|
||||
Log.dumpStack();
|
||||
shutdown(new Error("Socket closed unexpectedly."));
|
||||
shutdown(new Error(AuthCodes.NETWORK_ERROR));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,7 +321,10 @@ public class Communicator
|
||||
{
|
||||
log.info("Socket was closed: " + event);
|
||||
_client.notifyObservers(ClientEvent.CLIENT_CONNECTION_FAILED);
|
||||
shutdown(null);
|
||||
// if we hadn't loaded our client object yet, behave as if this was a logon failure because
|
||||
// we failed before we dispatched a DID_LOGON
|
||||
var wasLoggedOn :Boolean = (_client.getClientObject() != null);
|
||||
shutdown(wasLoggedOn ? null : new LogonError(AuthCodes.NETWORK_ERROR));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user