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:
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// $Id: TestDispatcher.java,v 1.1 2002/08/14 19:08:00 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.TestService;
|
||||
import com.threerings.presents.client.TestService.TestFuncListener;
|
||||
import com.threerings.presents.client.TestService.TestOidListener;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.data.TestMarshaller;
|
||||
import com.threerings.presents.server.InvocationDispatcher;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
|
||||
/**
|
||||
* Dispatches requests to the {@link TestProvider}.
|
||||
*/
|
||||
public class TestDispatcher extends InvocationDispatcher
|
||||
{
|
||||
/**
|
||||
* Creates a dispatcher that may be registered to dispatch invocation
|
||||
* service requests for the specified provider.
|
||||
*/
|
||||
public TestDispatcher (TestProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public InvocationMarshaller createMarshaller ()
|
||||
{
|
||||
return new TestMarshaller();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchRequest (
|
||||
ClientObject source, int methodId, Object[] args)
|
||||
throws InvocationException
|
||||
{
|
||||
switch (methodId) {
|
||||
case TestMarshaller.TEST:
|
||||
((TestProvider)provider).test(
|
||||
source,
|
||||
(String)args[0], ((Integer)args[1]).intValue(), (TestFuncListener)args[2]
|
||||
);
|
||||
return;
|
||||
|
||||
case TestMarshaller.GET_TEST_OID:
|
||||
((TestProvider)provider).getTestOid(
|
||||
source,
|
||||
(TestOidListener)args[0]
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,38 @@
|
||||
//
|
||||
// $Id: TestProvider.java,v 1.10 2001/11/08 02:57:03 mdb Exp $
|
||||
// $Id: TestProvider.java,v 1.11 2002/08/14 19:08:00 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
import com.threerings.presents.client.TestService;
|
||||
import com.threerings.presents.client.TestService.TestFuncListener;
|
||||
import com.threerings.presents.client.TestService.TestOidListener;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
|
||||
/**
|
||||
* A test of the invocation services.
|
||||
*/
|
||||
public class TestProvider extends InvocationProvider
|
||||
public class TestProvider implements InvocationProvider
|
||||
{
|
||||
public void handleTestRequest (
|
||||
ClientObject source, int invid, String one, int two)
|
||||
public void test (
|
||||
ClientObject caller, String one, int two, TestFuncListener listener)
|
||||
{
|
||||
Log.info("Test request [one=" + one + ", two=" + two + "].");
|
||||
|
||||
// issue a test notification just for kicks
|
||||
Object[] args = new Object[] { new Integer(1), "two" };
|
||||
PresentsServer.invmgr.sendNotification(
|
||||
source.getOid(), TestService.MODULE, "Test", args);
|
||||
TestSender.sendTest(caller, 1, "two");
|
||||
|
||||
// and issue a response to this invocation request
|
||||
sendResponse(source, invid, "TestSucceeded", one, new Integer(two));
|
||||
listener.testSucceeded(one, two);
|
||||
}
|
||||
|
||||
public void handleGetTestOidRequest (ClientObject source, int invid)
|
||||
public void getTestOid (ClientObject caller, TestOidListener listener)
|
||||
{
|
||||
Log.info("Handling get test oid [src=" + source.getOid() +
|
||||
", invid=" + invid + "].");
|
||||
int oid = TestServer.testobj.getOid();
|
||||
sendResponse(source, invid, "GotTestOid", new Integer(oid));
|
||||
Log.info("Handling get test oid [src=" + caller + "].");
|
||||
|
||||
// issue a test notification just for kicks
|
||||
TestSender.sendTest(caller, 1, "two");
|
||||
|
||||
listener.gotTestOid(TestServer.testobj.getOid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// $Id: TestSender.java,v 1.1 2002/08/14 19:08:01 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import com.threerings.presents.client.TestDecoder;
|
||||
import com.threerings.presents.client.TestReceiver;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationSender;
|
||||
|
||||
/**
|
||||
* Used to issue notifications to a {@link TestReceiver} instance on a
|
||||
* client.
|
||||
*/
|
||||
public class TestSender extends InvocationSender
|
||||
{
|
||||
/**
|
||||
* Issues a notification that will result in a call to {@link
|
||||
* TestReceiver#receivedTest} on a client.
|
||||
*/
|
||||
public static void sendTest (
|
||||
ClientObject target, int arg1, String arg2)
|
||||
{
|
||||
sendNotification(
|
||||
target, TestDecoder.RECEIVER_CODE, TestDecoder.RECEIVED_TEST,
|
||||
new Object[] { new Integer(arg1), arg2 });
|
||||
}
|
||||
|
||||
// Generated on 12:14:10 08/12/02.
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TestServer.java,v 1.8 2002/03/28 22:32:33 mdb Exp $
|
||||
// $Id: TestServer.java,v 1.9 2002/08/14 19:08:01 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
@@ -15,6 +15,9 @@ public class TestServer extends PresentsServer
|
||||
{
|
||||
super.init();
|
||||
|
||||
// register our test provider
|
||||
invmgr.registerDispatcher(new TestDispatcher(new TestProvider()), true);
|
||||
|
||||
// create a test object
|
||||
Subscriber sub = new Subscriber()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user