If we're going to do this, I guess we're going to do it properly. Nixed the

notion of a global group (though we implicitly define one in InvocationCodes)
added a mechanism for directors (which generally handle the client side of
invocation services) to register their interest in bootstrap service groups so
that the whole goddamned complex business can happen magically behind the
scenes.

If you instantiate a director, it will automatically register interest in the
service group it needs and everything will work. If you don't use the director
code, you don't get the services and you can safely exclude all of that code
from your client even though the services are still in use on the server (and
presumably used by some other types of clients).

This is going to break all the builds, which I'll soon fix. Then I'll go write
all this in ActionScript. Yay!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4552 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-02-11 01:17:30 +00:00
parent 9afcc526a0
commit ebc99935d5
25 changed files with 406 additions and 358 deletions
@@ -24,19 +24,17 @@ package com.threerings.presents.client;
import com.threerings.presents.util.PresentsContext;
/**
* Handles functionality common to nearly all client directors. They
* generally need to be session observers so that they can set themselves
* up when the client logs on (by overriding {@link #clientDidLogon}) and
* clean up after themselves when the client logs off (by overriding
* {@link #clientDidLogoff}).
* Handles functionality common to nearly all client directors. They generally need to be session
* observers so that they can set themselves up when the client logs on (by overriding {@link
* #clientDidLogon}) and clean up after themselves when the client logs off (by overriding {@link
* #clientDidLogoff}).
*/
public class BasicDirector
implements SessionObserver
{
/**
* Derived directors will need to provide the basic director with a
* context that it can use to register itself with the necessary
* entities.
* Derived directors will need to provide the basic director with a context that it can use to
* register itself with the necessary entities.
*/
protected BasicDirector (PresentsContext ctx)
{
@@ -56,6 +54,12 @@ public class BasicDirector
}
}
// documentation inherited from interface
public void clientWillLogon (Client client)
{
registerServices(client);
}
// documentation inherited from interface
public void clientDidLogon (Client client)
{
@@ -85,8 +89,7 @@ public class BasicDirector
}
/**
* 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).
*/
public boolean isAvailableInStandalone ()
{
@@ -102,8 +105,7 @@ public class BasicDirector
}
/**
* If this director is not currently available, throws a
* {@link RuntimeException}.
* If this director is not currently available, throws a {@link RuntimeException}.
*/
protected void assertAvailable ()
{
@@ -114,20 +116,27 @@ public class BasicDirector
}
/**
* 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.
* 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.
*/
protected void clientObjectUpdated (Client client)
{
}
/**
* Derived directors can override this method and obtain any services
* they'll need during their operation via calls to {@link
* Client#getService}. If the director is available, it will automatically
* be called when the client logs on or when the director is constructed
* if it is constructed after the client is already logged on.
* If a director makes use of bootstrap invocation services which are part of a bootstrap
* service group, it should register interest in that group here with a call to {@link
* Client#addServiceGroup}.
*/
protected void registerServices (Client client)
{
}
/**
* Derived directors can override this method and obtain any services they'll need during their
* operation via calls to {@link Client#getService}. If the director is available, it will
* automatically be called when the client logs on or when the director is constructed if it is
* constructed after the client is already logged on.
*/
protected void fetchServices (Client client)
{