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
@@ -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));
}
/**
@@ -26,22 +26,24 @@ package com.threerings.presents.data {
*/
public class AuthCodes
{
/** A code indicating that no user exists with the specified
* username. */
/** A code indicating that no user exists with the specified username. */
public static const NO_SUCH_USER :String = "m.no_such_user";
/** A code indicating that the supplied password was invalid. */
public static const INVALID_PASSWORD :String = "m.invalid_password";
/** A code indicating that an internal server error occurred while
* trying to log the user on. */
/** A code indicating that an internal server error occurred while trying to log the user
* on. */
public static const SERVER_ERROR :String = "m.server_error";
/** A code indicating that a network error occurred while trying to log the user on. */
public static const NETWORK_ERROR :String = "m.network_error";
/** A code indicating that the server is not available at the moment. */
public static const SERVER_UNAVAILABLE :String = "m.server_unavailable";
/** A code indicating that we failed to connect to the server on a port and
* are trying the next port in the list. */
/** A code indicating that we failed to connect to the server on a port and are trying the next
* port in the list. */
public static const TRYING_NEXT_PORT :String = "m.trying_next_port";
}
}