We need to run willLogon() immediately, also modified BasicDirector and Client
to fail if a director tries to register services groups but was not created until after the client was logged on. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4557 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -48,6 +48,9 @@ public class BasicDirector
|
|||||||
// if we're already logged on, fire off a call to fetch services
|
// if we're already logged on, fire off a call to fetch services
|
||||||
if (client.isLoggedOn()) {
|
if (client.isLoggedOn()) {
|
||||||
if (isAvailable()) {
|
if (isAvailable()) {
|
||||||
|
// this is a sanity check: it will fail if this post-logon initialized director
|
||||||
|
// claims to need service groups (it must make that known prior to logon)
|
||||||
|
registerServices(client);
|
||||||
fetchServices(client);
|
fetchServices(client);
|
||||||
}
|
}
|
||||||
clientObjectUpdated(client);
|
clientObjectUpdated(client);
|
||||||
|
|||||||
@@ -266,6 +266,9 @@ public class Client
|
|||||||
*/
|
*/
|
||||||
public void addServiceGroup (String group)
|
public void addServiceGroup (String group)
|
||||||
{
|
{
|
||||||
|
if (isLoggedOn()) {
|
||||||
|
throw new IllegalStateException("Service groups must be registered prior to logon.");
|
||||||
|
}
|
||||||
_bootGroups.add(group);
|
_bootGroups.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +567,7 @@ public class Client
|
|||||||
notifyObservers(CLIENT_OBJECT_CHANGED, null);
|
notifyObservers(CLIENT_OBJECT_CHANGED, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean notifyObservers (int code, Exception cause)
|
protected boolean notifyObservers (int code, Exception cause)
|
||||||
{
|
{
|
||||||
final Notifier noty = new Notifier(code, cause);
|
final Notifier noty = new Notifier(code, cause);
|
||||||
Runnable unit = new Runnable() {
|
Runnable unit = new Runnable() {
|
||||||
@@ -575,10 +578,10 @@ public class Client
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// we need to run immediately if this is WILL_LOGOFF or if we have no RunQueue (which
|
// we need to run immediately if this is WILL_LOGON, WILL_LOGOFF or if we have no RunQueue
|
||||||
// currently only happens in some really obscure circumstances where we're using a Client
|
// (which currently only happens in some really obscure circumstances where we're using a
|
||||||
// instance on the server so that we can sort of pretend to be a real client)
|
// Client instance on the server so that we can sort of pretend to be a real client)
|
||||||
if (code == CLIENT_WILL_LOGOFF || _runQueue == null) {
|
if (code == CLIENT_WILL_LOGON || code == CLIENT_WILL_LOGOFF || _runQueue == null) {
|
||||||
unit.run();
|
unit.run();
|
||||||
return noty.getRejected();
|
return noty.getRejected();
|
||||||
|
|
||||||
@@ -590,7 +593,7 @@ public class Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void cleanup (final Exception logonError)
|
protected synchronized void cleanup (final Exception logonError)
|
||||||
{
|
{
|
||||||
// we know that prior to the call to this method, the observers were notified with
|
// we know that prior to the call to this method, the observers were notified with
|
||||||
// CLIENT_DID_LOGOFF; that may not have been invoked yet, so we don't want to clear out our
|
// CLIENT_DID_LOGOFF; that may not have been invoked yet, so we don't want to clear out our
|
||||||
@@ -625,7 +628,7 @@ public class Client
|
|||||||
* Called when we receive a pong packet. We may be in the process of calculating the client/
|
* Called when we receive a pong packet. We may be in the process of calculating the client/
|
||||||
* server time differential, or we may have already done that at which point we ignore pongs.
|
* server time differential, or we may have already done that at which point we ignore pongs.
|
||||||
*/
|
*/
|
||||||
void gotPong (PongResponse pong)
|
protected void gotPong (PongResponse pong)
|
||||||
{
|
{
|
||||||
// if we're not currently calculating our delta, then we can throw away the pong
|
// if we're not currently calculating our delta, then we can throw away the pong
|
||||||
if (_dcalc != null) {
|
if (_dcalc != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user