Created a test service and provider and sorted out further details.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@71 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Client.java,v 1.8 2001/07/19 07:09:16 mdb Exp $
|
||||
// $Id: Client.java,v 1.9 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.client;
|
||||
|
||||
@@ -253,6 +253,9 @@ public class Client
|
||||
|
||||
// create our invocation manager
|
||||
_invmgr = new InvocationManager(this, data.invOid);
|
||||
|
||||
// let the client know that logon has now fully succeeded
|
||||
notifyObservers(Client.CLIENT_DID_LOGON, null);
|
||||
}
|
||||
|
||||
protected Credentials _creds;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Communicator.java,v 1.9 2001/07/19 07:09:16 mdb Exp $
|
||||
// $Id: Communicator.java,v 1.10 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.client;
|
||||
|
||||
@@ -163,8 +163,8 @@ public class Communicator
|
||||
_writer = new Writer();
|
||||
_writer.start();
|
||||
|
||||
// let the client know that logon succeeded
|
||||
_client.notifyObservers(Client.CLIENT_DID_LOGON, null);
|
||||
// wait for the bootstrap notification before we claim that we're
|
||||
// actually logged on
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,6 +365,7 @@ public class Communicator
|
||||
|
||||
} catch (ObjectStreamException ose) {
|
||||
Log.warning("Error decoding message: " + ose);
|
||||
Log.logStackTrace(ose);
|
||||
|
||||
} catch (InterruptedIOException iioe) {
|
||||
// somebody set up us the bomb! we've been interrupted
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TypedObjectRegistry.java,v 1.1 2001/06/11 17:44:04 mdb Exp $
|
||||
// $Id: TypedObjectRegistry.java,v 1.2 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.io;
|
||||
|
||||
@@ -36,6 +36,8 @@ public class TypedObjectRegistry
|
||||
// register our downstream message classes
|
||||
TypedObjectFactory.registerClass(AuthResponse.TYPE,
|
||||
AuthResponse.class);
|
||||
TypedObjectFactory.registerClass(BootstrapNotification.TYPE,
|
||||
BootstrapNotification.class);
|
||||
TypedObjectFactory.registerClass(EventNotification.TYPE,
|
||||
EventNotification.class);
|
||||
TypedObjectFactory.registerClass(ObjectResponse.TYPE,
|
||||
@@ -54,5 +56,7 @@ public class TypedObjectRegistry
|
||||
AttributeChangedEvent.class);
|
||||
TypedObjectFactory.registerClass(AttributesChangedEvent.TYPE,
|
||||
AttributesChangedEvent.class);
|
||||
TypedObjectFactory.registerClass(MessageEvent.TYPE,
|
||||
MessageEvent.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: InvocationManager.java,v 1.2 2001/07/19 07:09:16 mdb Exp $
|
||||
// $Id: InvocationManager.java,v 1.3 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class InvocationManager
|
||||
return true;
|
||||
}
|
||||
|
||||
// make sure the name is proper just for sanities sake
|
||||
// make sure the name is proper just for sanity's sake
|
||||
MessageEvent mevt = (MessageEvent)event;
|
||||
if (!mevt.getName().equals(InvocationObject.MESSAGE_NAME)) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsClient.java,v 1.6 2001/07/19 07:17:46 mdb Exp $
|
||||
// $Id: PresentsClient.java,v 1.7 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -107,6 +107,8 @@ public class Client implements Subscriber, MessageHandler
|
||||
*/
|
||||
protected void sendBootstrap ()
|
||||
{
|
||||
Log.info("Sending bootstrap [client=" + this + "].");
|
||||
|
||||
// create and populate our bootstrap data
|
||||
BootstrapData data = createBootstrapData();
|
||||
populateBootstrapData(data);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsServer.java,v 1.6 2001/07/19 07:09:16 mdb Exp $
|
||||
// $Id: PresentsServer.java,v 1.7 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.threerings.cocktail.cher.server.net.AuthManager;
|
||||
import com.threerings.cocktail.cher.server.net.ConnectionManager;
|
||||
|
||||
import com.threerings.cocktail.cher.server.test.TestObject;
|
||||
import com.threerings.cocktail.cher.server.test.TestProvider;
|
||||
import com.threerings.cocktail.cher.client.test.TestService;
|
||||
|
||||
/**
|
||||
* The cher server provides a central point of access to the various
|
||||
@@ -51,6 +53,9 @@ public class CherServer
|
||||
// create an object for testing
|
||||
omgr.createObject(TestObject.class, null, false);
|
||||
|
||||
// register our test provider
|
||||
invmgr.registerProvider(TestService.MODULE, new TestProvider());
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to initialize server.");
|
||||
Log.logStackTrace(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TestClient.java,v 1.4 2001/06/13 05:17:55 mdb Exp $
|
||||
// $Id: TestClient.java,v 1.5 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.client.test;
|
||||
|
||||
@@ -37,7 +37,9 @@ public class TestClient
|
||||
{
|
||||
Log.info("Client did logon [client=" + client + "].");
|
||||
// try subscribing to a test object
|
||||
client.getDObjectManager().subscribeToObject(1, this);
|
||||
client.getDObjectManager().subscribeToObject(2, this);
|
||||
// issue a test invocation request
|
||||
TestService.test(client, "foo", 1, this);
|
||||
}
|
||||
|
||||
public void clientFailedToLogon (Client client, Exception cause)
|
||||
@@ -85,6 +87,11 @@ public class TestClient
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleTestSucceeded (String response)
|
||||
{
|
||||
Log.info("Got test response [rsp=" + response + "].");
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
TestClient tclient = new TestClient();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// $Id: TestService.java,v 1.1 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.client.test;
|
||||
|
||||
import com.threerings.cocktail.cher.Log;
|
||||
import com.threerings.cocktail.cher.client.Client;
|
||||
import com.threerings.cocktail.cher.client.InvocationManager;
|
||||
|
||||
/**
|
||||
* A test of the invocation services.
|
||||
*/
|
||||
public class TestService
|
||||
{
|
||||
public static final String MODULE = "test";
|
||||
|
||||
public static void test (
|
||||
Client client, String one, int two, Object rsptarget)
|
||||
{
|
||||
InvocationManager invmgr = client.getInvocationManager();
|
||||
Object[] args = new Object[] { one, new Integer(two) };
|
||||
invmgr.invoke(MODULE, "Test", args, rsptarget);
|
||||
Log.info("Sent test request [one=" + one + ", two=" + two + "].");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// $Id: TestProvider.java,v 1.1 2001/07/19 07:48:25 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server.test;
|
||||
|
||||
import com.threerings.cocktail.cher.Log;
|
||||
|
||||
/**
|
||||
* A test of the invocation services.
|
||||
*/
|
||||
public class TestProvider
|
||||
{
|
||||
public Object[] handleTestRequest (String one, int two)
|
||||
{
|
||||
Log.info("Test request [one=" + one + ", two=" + two + "].");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user