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:
Michael Bayne
2009-03-19 23:40:03 +00:00
parent 0da49cb6ab
commit 5d0a86c698
3 changed files with 20 additions and 11 deletions
@@ -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));
}
/**