Annoyingly, ClientObserver.clientDidLogoff() is called before the client's
inner bits are all clear and ready to try logging on to a new server. We specifically wait to call clientLogonFailed() until after everything is cleared, but I don't want to change the behavior of clientDidLogoff() for fear that any one of the zillion directors depends on something being around during that call. Instead I added another callback clientDidClear() that is called when a successful session is fulled cleared out (basically when we're not calling clientLogonFailed()) so that entities that are waiting for a logoff to finish so that they can logon somewhere else have a clean way of doing so. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4255 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -632,6 +632,8 @@ public class Client
|
||||
// changed like the server or port)
|
||||
if (logonError != null) {
|
||||
notifyObservers(CLIENT_FAILED_TO_LOGON, logonError);
|
||||
} else {
|
||||
notifyObservers(CLIENT_DID_CLEAR, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -712,6 +714,12 @@ public class Client
|
||||
obs.clientDidLogoff(Client.this);
|
||||
break;
|
||||
|
||||
case CLIENT_DID_CLEAR:
|
||||
if (obs instanceof ClientObserver) {
|
||||
((ClientObserver)obs).clientDidClear(Client.this);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Invalid code supplied to " +
|
||||
"notifyObservers: " + _code);
|
||||
@@ -797,4 +805,5 @@ public class Client
|
||||
static final int CLIENT_CONNECTION_FAILED = 3;
|
||||
static final int CLIENT_WILL_LOGOFF = 4;
|
||||
static final int CLIENT_DID_LOGOFF = 5;
|
||||
static final int CLIENT_DID_CLEAR = 6;
|
||||
}
|
||||
|
||||
@@ -62,4 +62,9 @@ public class ClientAdapter implements ClientObserver
|
||||
public void clientDidLogoff (Client client)
|
||||
{
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientDidClear (Client client)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,4 +77,13 @@ public interface ClientObserver extends SessionObserver
|
||||
* request.
|
||||
*/
|
||||
public boolean clientWillLogoff (Client client);
|
||||
|
||||
/**
|
||||
* Called after the client is completely logged off from a successful
|
||||
* session and is ready to reconnect to a new server if desired. This will
|
||||
* only be called after an active session was terminated, not after a logon
|
||||
* attempt failed as that failure will be reported by {@link
|
||||
* #clientFailedToLogon}.
|
||||
*/
|
||||
public void clientDidClear (Client client);
|
||||
}
|
||||
|
||||
@@ -418,6 +418,12 @@ public class PeerManager
|
||||
// TODO: clean things up?
|
||||
}
|
||||
|
||||
// documentation inherited from interface ClientObserver
|
||||
public void clientDidClear (Client client)
|
||||
{
|
||||
// nothing doing
|
||||
}
|
||||
|
||||
// documentation inherited from interface Subscriber
|
||||
public void objectAvailable (NodeObject object)
|
||||
{
|
||||
|
||||
@@ -120,6 +120,10 @@ public class TestClient
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void clientDidClear (Client client)
|
||||
{
|
||||
}
|
||||
|
||||
protected CrowdContext createContext ()
|
||||
{
|
||||
return new CrowdContextImpl();
|
||||
|
||||
Reference in New Issue
Block a user