Dispatch the notification that the client failed to logon after we are
completely cleaned up so that an immediate attempt to logon using a different configuration will not fail due to the client thinking it's still logged on from the previous failed attempt. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3658 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -431,7 +431,7 @@ public class Client
|
|||||||
public void standaloneLogoff ()
|
public void standaloneLogoff ()
|
||||||
{
|
{
|
||||||
notifyObservers(CLIENT_DID_LOGOFF, null);
|
notifyObservers(CLIENT_DID_LOGOFF, null);
|
||||||
cleanup();
|
cleanup(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -529,7 +529,7 @@ public class Client
|
|||||||
_clobj = clobj;
|
_clobj = clobj;
|
||||||
|
|
||||||
// let the client know that logon has now fully succeeded
|
// let the client know that logon has now fully succeeded
|
||||||
notifyObservers(Client.CLIENT_DID_LOGON, null);
|
notifyObservers(CLIENT_DID_LOGON, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -539,7 +539,7 @@ public class Client
|
|||||||
protected void getClientObjectFailed (Exception cause)
|
protected void getClientObjectFailed (Exception cause)
|
||||||
{
|
{
|
||||||
// pass the buck onto the listeners
|
// pass the buck onto the listeners
|
||||||
notifyObservers(Client.CLIENT_FAILED_TO_LOGON, cause);
|
notifyObservers(CLIENT_FAILED_TO_LOGON, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -552,7 +552,7 @@ public class Client
|
|||||||
_cloid = _clobj.getOid();
|
_cloid = _clobj.getOid();
|
||||||
|
|
||||||
// report to our observers
|
// report to our observers
|
||||||
notifyObservers(Client.CLIENT_OBJECT_CHANGED, null);
|
notifyObservers(CLIENT_OBJECT_CHANGED, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean notifyObservers (int code, Exception cause)
|
boolean notifyObservers (int code, Exception cause)
|
||||||
@@ -582,7 +582,7 @@ public class Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void cleanup ()
|
synchronized void cleanup (final Exception logonError)
|
||||||
{
|
{
|
||||||
// we know that prior to the call to this method, the observers
|
// we know that prior to the call to this method, the observers
|
||||||
// were notified with CLIENT_DID_LOGOFF; that may not have been
|
// were notified with CLIENT_DID_LOGOFF; that may not have been
|
||||||
@@ -598,8 +598,18 @@ public class Client
|
|||||||
_clobj = null;
|
_clobj = null;
|
||||||
_cloid = -1;
|
_cloid = -1;
|
||||||
_standalone = false;
|
_standalone = false;
|
||||||
|
|
||||||
// and let our invocation director know we're logged off
|
// and let our invocation director know we're logged off
|
||||||
_invdir.cleanup();
|
_invdir.cleanup();
|
||||||
|
|
||||||
|
// if we were cleaned up due to a failure to logon, we can
|
||||||
|
// report the logon error now that the communicator is
|
||||||
|
// cleaned up; this allows a logon failure listener to
|
||||||
|
// immediately try another logon (hopefully with something
|
||||||
|
// changed like the server or port)
|
||||||
|
if (logonError != null) {
|
||||||
|
notifyObservers(CLIENT_FAILED_TO_LOGON, logonError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ public class Communicator
|
|||||||
closeChannel();
|
closeChannel();
|
||||||
|
|
||||||
// let the client know when we finally go away
|
// let the client know when we finally go away
|
||||||
_client.cleanup();
|
_client.cleanup(_logonError);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Reader thread exited.");
|
Log.debug("Reader thread exited.");
|
||||||
@@ -271,7 +271,7 @@ public class Communicator
|
|||||||
|
|
||||||
// let the client know when we finally go away
|
// let the client know when we finally go away
|
||||||
if (_reader == null) {
|
if (_reader == null) {
|
||||||
_client.cleanup();
|
_client.cleanup(_logonError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,9 +413,9 @@ public class Communicator
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.debug("Logon failed: " + e);
|
Log.debug("Logon failed: " + e);
|
||||||
Log.logStackTrace(e);
|
Log.logStackTrace(e);
|
||||||
// let the observers know that we've failed
|
// once we're shutdown we'll report this error
|
||||||
_client.notifyObservers(Client.CLIENT_FAILED_TO_LOGON, e);
|
_logonError = e;
|
||||||
// and terminate our communicator thread
|
// terminate our communicator thread
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,6 +602,7 @@ public class Communicator
|
|||||||
protected Queue _msgq = new Queue();
|
protected Queue _msgq = new Queue();
|
||||||
|
|
||||||
protected long _lastWrite;
|
protected long _lastWrite;
|
||||||
|
protected Exception _logonError;
|
||||||
|
|
||||||
/** We use this to frame our upstream messages. */
|
/** We use this to frame our upstream messages. */
|
||||||
protected FramingOutputStream _fout;
|
protected FramingOutputStream _fout;
|
||||||
|
|||||||
Reference in New Issue
Block a user