Added support for streaming List and ArrayList natively. A List will be

unmarshalled into an ArrayList on the receiver. Along the way, I improved
support for generic types as arguments to invocation services (which required
one unfortunate "sweeping" warning suppression, but since this is in generated
code, I think we can be sure it won't be doing anything untoward).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4375 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-09-19 00:31:50 +00:00
parent 036271438a
commit afad7dd444
15 changed files with 271 additions and 131 deletions
@@ -1,8 +1,8 @@
//
// $Id: TestDispatcher.java,v 1.2 2004/08/27 02:21:04 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
@@ -21,15 +21,13 @@
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;
import java.util.ArrayList;
/**
* Dispatches requests to the {@link TestProvider}.
@@ -51,28 +49,29 @@ public class TestDispatcher extends InvocationDispatcher
return new TestMarshaller();
}
// documentation inherited
@SuppressWarnings("unchecked") // 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]
(TestService.TestOidListener)args[0]
);
return;
case TestMarshaller.TEST:
((TestProvider)provider).test(
source,
(String)args[0], ((Integer)args[1]).intValue(), (ArrayList<java.lang.Integer>)args[2], (TestService.TestFuncListener)args[3]
);
return;
default:
super.dispatchRequest(source, methodId, args);
return;
}
}
}
@@ -0,0 +1,44 @@
//
// $Id$
package com.threerings.presents.server;
import java.util.ArrayList;
import com.samskivert.util.StringUtil;
import com.threerings.presents.Log;
import com.threerings.presents.client.TestService;
import com.threerings.presents.data.ClientObject;
/**
* Implements the server side of the TestProvider interface.
*/
public class TestManager
implements TestProvider
{
// from interface TestProvider
public void getTestOid (ClientObject caller,
TestService.TestOidListener listener)
throws InvocationException
{
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());
}
// from interface TestProvider
public void test (ClientObject caller, String one, int two,
ArrayList<Integer> three, TestService.TestFuncListener listener)
throws InvocationException
{
Log.info("Test request [one=" + one + ", two=" + two +
", three=" + StringUtil.toString(three) + "].");
// and issue a response to this invocation request
listener.testSucceeded(one, two);
}
}
@@ -1,8 +1,8 @@
//
// $Id: TestProvider.java,v 1.12 2004/08/27 02:21:04 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
@@ -21,36 +21,26 @@
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;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider;
import java.util.ArrayList;
/**
* A test of the invocation services.
* Defines the server-side of the {@link TestService}.
*/
public class TestProvider implements InvocationProvider
public interface TestProvider extends InvocationProvider
{
public void test (
ClientObject caller, String one, int two, TestFuncListener listener)
{
Log.info("Test request [one=" + one + ", two=" + two + "].");
/**
* Handles a {@link TestService#getTestOid} request.
*/
public void getTestOid (ClientObject caller, TestService.TestOidListener arg1)
throws InvocationException;
// issue a test notification just for kicks
TestSender.sendTest(caller, 1, "two");
// and issue a response to this invocation request
listener.testSucceeded(one, two);
}
public void getTestOid (ClientObject caller, TestOidListener listener)
{
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());
}
/**
* Handles a {@link TestService#test} request.
*/
public void test (ClientObject caller, String arg1, int arg2, ArrayList<java.lang.Integer> arg3, TestService.TestFuncListener arg4)
throws InvocationException;
}
@@ -35,10 +35,14 @@ public class TestServer extends PresentsServer
super.init();
// register our test provider
invmgr.registerDispatcher(new TestDispatcher(new TestProvider()), true);
invmgr.registerDispatcher(new TestDispatcher(new TestManager()), true);
// create a test object
testobj = omgr.registerObject(new TestObject());
testobj.longs.add(System.currentTimeMillis());
long value = Integer.MAX_VALUE;
value++;
testobj.longs.add(value);
}
public static void main (String[] args)