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:
@@ -40,7 +40,7 @@ public class BasicDirector
|
|||||||
{
|
{
|
||||||
// save context
|
// save context
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
|
||||||
// listen for session start and end
|
// listen for session start and end
|
||||||
Client client = ctx.getClient();
|
Client client = ctx.getClient();
|
||||||
client.addClientObserver(this);
|
client.addClientObserver(this);
|
||||||
@@ -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);
|
||||||
@@ -87,7 +90,7 @@ public class BasicDirector
|
|||||||
{
|
{
|
||||||
_availableInStandalone = available;
|
_availableInStandalone = available;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether or not this director is available in standalone mode (defaults to false).
|
* Checks whether or not this director is available in standalone mode (defaults to false).
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +98,7 @@ public class BasicDirector
|
|||||||
{
|
{
|
||||||
return _availableInStandalone;
|
return _availableInStandalone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this director is available in the current mode.
|
* Checks whether this director is available in the current mode.
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +106,7 @@ public class BasicDirector
|
|||||||
{
|
{
|
||||||
return isAvailableInStandalone() || !_ctx.getClient().isStandalone();
|
return isAvailableInStandalone() || !_ctx.getClient().isStandalone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this director is not currently available, throws a {@link RuntimeException}.
|
* If this director is not currently available, throws a {@link RuntimeException}.
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +117,7 @@ public class BasicDirector
|
|||||||
" not available in standalone mode!");
|
" not available in standalone mode!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called in three circumstances: when a director is created and we've already logged on; when
|
* 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.
|
* 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. */
|
/** The application context. */
|
||||||
protected PresentsContext _ctx;
|
protected PresentsContext _ctx;
|
||||||
|
|
||||||
/** Whether or not this director is available in standalone mode. */
|
/** Whether or not this director is available in standalone mode. */
|
||||||
protected boolean _availableInStandalone;
|
protected boolean _availableInStandalone;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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