The great invocation services rethink of 2002! Rearchitected the remote

method invocation services and converted everything to the new style.
Could this be my biggest checkin ever?


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1642 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-08-14 19:08:01 +00:00
parent 4481c5f835
commit e54a4d41f4
161 changed files with 6083 additions and 2805 deletions
@@ -1,5 +1,5 @@
//
// $Id: TestClient.java,v 1.13 2002/02/09 20:47:11 mdb Exp $
// $Id: TestClient.java,v 1.14 2002/08/14 19:07:59 mdb Exp $
package com.threerings.presents.client;
@@ -14,7 +14,9 @@ import com.threerings.presents.server.TestObject;
* A standalone test client.
*/
public class TestClient
implements Client.Invoker, ClientObserver, Subscriber, EventListener
implements Client.Invoker, SessionObserver, Subscriber, EventListener,
TestService.TestFuncListener, TestService.TestOidListener,
TestReceiver
{
public void setClient (Client client)
{
@@ -39,29 +41,15 @@ public class TestClient
public void clientDidLogon (Client client)
{
Log.info("Client did logon [client=" + client + "].");
// register our test notification receiver
client.getInvocationDirector().registerReceiver(TestService.MODULE,
new TestReceiver());
// register ourselves as a test notification receiver
client.getInvocationDirector().registerReceiver(
new TestDecoder(this));
// get the test object id
TestService.getTestOid(client, this);
}
public void clientFailedToLogon (Client client, Exception cause)
{
Log.info("Client failed to logon [client=" + client +
", cause=" + cause + "].");
}
public void clientConnectionFailed (Client client, Exception cause)
{
Log.info("Client connection failed [client=" + client +
", cause=" + cause + "].");
}
public boolean clientWillLogoff (Client client)
{
Log.info("Client will logoff [client=" + client + "].");
return true;
TestService service = (TestService)
client.requireService(TestService.class);
service.getTestOid(client, this);
}
public void clientDidLogoff (Client client)
@@ -99,15 +87,30 @@ public class TestClient
}
}
public void handleTestSucceeded (int invid, String one, int two)
// documentation inherited from interface
public void testSucceeded (String one, int two)
{
Log.info("Got test response [one=" + one + ", two=" + two + "].");
}
public void handleGotTestOid (int invid, int oid)
// documentation inherited from interface
public void gotTestOid (int testOid)
{
// subscribe to the test object
_client.getDObjectManager().subscribeToObject(oid, this);
_client.getDObjectManager().subscribeToObject(testOid, this);
}
// documentation inherited from interface
public void requestFailed (String reason)
{
Log.info("Urk! Request failed [reason=" + reason + "].");
}
// documentation inherited from interface
public void receivedTest (int one, String two)
{
Log.info("Received test notification [one=" + one +
", two=" + two + "].");
}
public static void main (String[] args)
@@ -0,0 +1,52 @@
//
// $Id: TestDecoder.java,v 1.1 2002/08/14 19:07:59 mdb Exp $
package com.threerings.presents.client;
import com.threerings.presents.client.InvocationDecoder;
import com.threerings.presents.client.TestReceiver;
/**
* Dispatches calls to a {@link TestReceiver} instance.
*/
public class TestDecoder extends InvocationDecoder
{
/** The generated hash code used to identify this receiver class. */
public static final String RECEIVER_CODE = "b4b66d24b85d870d04c8da3524c188eb";
/** The method id used to dispatch {@link TestReceiver#receivedTest}
* notifications. */
public static final int RECEIVED_TEST = 1;
/**
* Creates a decoder that may be registered to dispatch invocation
* service notifications to the specified receiver.
*/
public TestDecoder (TestReceiver receiver)
{
this.receiver = receiver;
}
// documentation inherited
public String getReceiverCode ()
{
return RECEIVER_CODE;
}
// documentation inherited
public void dispatchNotification (int methodId, Object[] args)
{
switch (methodId) {
case RECEIVED_TEST:
((TestReceiver)receiver).receivedTest(
((Integer)args[0]).intValue(), (String)args[1]
);
return;
default:
super.dispatchNotification(methodId, args);
}
}
// Generated on 12:14:10 08/12/02.
}
@@ -1,15 +1,15 @@
//
// $Id: TestReceiver.java,v 1.5 2001/11/08 02:07:36 mdb Exp $
// $Id: TestReceiver.java,v 1.6 2002/08/14 19:07:59 mdb Exp $
package com.threerings.presents.client;
import com.threerings.presents.Log;
public class TestReceiver implements InvocationReceiver
/**
* A test of the invocation notification services.
*/
public interface TestReceiver extends InvocationReceiver
{
public void handleTestNotification (int invid, int one, String two)
{
Log.info("Received tell notification [invid=" + invid +
", one=" + one + ", two=" + two + "].");
}
/**
* Dispatches a test notification.
*/
public void receivedTest (int one, String two);
}
@@ -1,30 +1,31 @@
//
// $Id: TestService.java,v 1.5 2001/11/08 02:07:36 mdb Exp $
// $Id: TestService.java,v 1.6 2002/08/14 19:07:59 mdb Exp $
package com.threerings.presents.client;
import com.threerings.presents.Log;
/**
* A test of the invocation services.
*/
public class TestService
public interface TestService extends InvocationService
{
public static final String MODULE = "test";
public static void test (
Client client, String one, int two, Object rsptarget)
/** Used to dispatch responses to {@link #test} requests. */
public static interface TestFuncListener extends InvocationListener
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] { one, new Integer(two) };
invdir.invoke(MODULE, "Test", args, rsptarget);
Log.info("Sent test request [one=" + one + ", two=" + two + "].");
/** Informs listener of successful {@link #test} request. */
public void testSucceeded (String one, int two);
}
public static void getTestOid (Client client, Object rsptarget)
/** Issues a test request. */
public void test (
Client client, String one, int two, TestFuncListener listener);
/** Used to dispatch responses to {@link #getTestOid} requests. */
public static interface TestOidListener extends InvocationListener
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[0];
invdir.invoke(MODULE, "GetTestOid", args, rsptarget);
/** Communicates test oid to listener. */
public void gotTestOid (int testOid);
}
/** Issues a request for the test oid. */
public void getTestOid (Client client, TestOidListener listener);
}