diff --git a/src/java/com/threerings/presents/client/BasicDirector.java b/src/java/com/threerings/presents/client/BasicDirector.java index f22e16a76..0c93766d1 100644 --- a/src/java/com/threerings/presents/client/BasicDirector.java +++ b/src/java/com/threerings/presents/client/BasicDirector.java @@ -40,7 +40,7 @@ public class BasicDirector { // save context _ctx = ctx; - + // listen for session start and end Client client = ctx.getClient(); client.addClientObserver(this); @@ -48,6 +48,9 @@ public class BasicDirector // if we're already logged on, fire off a call to fetch services if (client.isLoggedOn()) { 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); } clientObjectUpdated(client); @@ -87,7 +90,7 @@ public class BasicDirector { _availableInStandalone = available; } - + /** * Checks whether or not this director is available in standalone mode (defaults to false). */ @@ -95,7 +98,7 @@ public class BasicDirector { return _availableInStandalone; } - + /** * Checks whether this director is available in the current mode. */ @@ -103,7 +106,7 @@ public class BasicDirector { return isAvailableInStandalone() || !_ctx.getClient().isStandalone(); } - + /** * If this director is not currently available, throws a {@link RuntimeException}. */ @@ -114,7 +117,7 @@ public class BasicDirector " not available in standalone mode!"); } } - + /** * Called in three circumstances: when a director is created and we've already logged on; when * we first log on and when the client object changes after we've already logged on. @@ -144,7 +147,7 @@ public class BasicDirector /** The application context. */ protected PresentsContext _ctx; - + /** Whether or not this director is available in standalone mode. */ protected boolean _availableInStandalone; } diff --git a/src/java/com/threerings/presents/client/Client.java b/src/java/com/threerings/presents/client/Client.java index b6dde2f06..7daeb1a12 100644 --- a/src/java/com/threerings/presents/client/Client.java +++ b/src/java/com/threerings/presents/client/Client.java @@ -266,6 +266,9 @@ public class Client */ public void addServiceGroup (String group) { + if (isLoggedOn()) { + throw new IllegalStateException("Service groups must be registered prior to logon."); + } _bootGroups.add(group); } @@ -564,7 +567,7 @@ public class Client 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); 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 - // currently only happens in some really obscure circumstances where we're using a Client - // instance on the server so that we can sort of pretend to be a real client) - if (code == CLIENT_WILL_LOGOFF || _runQueue == null) { + // we need to run immediately if this is WILL_LOGON, WILL_LOGOFF or if we have no RunQueue + // (which currently only happens in some really obscure circumstances where we're using a + // Client instance on the server so that we can sort of pretend to be a real client) + if (code == CLIENT_WILL_LOGON || code == CLIENT_WILL_LOGOFF || _runQueue == null) { unit.run(); 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 // 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/ * 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 (_dcalc != null) {