Log class jockeying; implemented a test client at the party layer that
does proper context object creation; small progress on locmgr stuff. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@95 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// $Id: Log.java,v 1.1 2001/07/20 23:23:50 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.cocktail.party;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A placeholder class that contains a reference to the log object used by
|
||||||
|
* the Party services.
|
||||||
|
*/
|
||||||
|
public class Log
|
||||||
|
{
|
||||||
|
public static com.samskivert.util.Log log =
|
||||||
|
new com.samskivert.util.Log("cocktail.party");
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void debug (String message)
|
||||||
|
{
|
||||||
|
log.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void info (String message)
|
||||||
|
{
|
||||||
|
log.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void warning (String message)
|
||||||
|
{
|
||||||
|
log.warning(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convenience function. */
|
||||||
|
public static void logStackTrace (Throwable t)
|
||||||
|
{
|
||||||
|
log.logStackTrace(com.samskivert.util.Log.WARNING, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
//
|
//
|
||||||
// $Id: LocationDirector.java,v 1.1 2001/07/20 20:07:37 mdb Exp $
|
// $Id: LocationDirector.java,v 1.2 2001/07/20 23:23:50 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.client;
|
package com.threerings.cocktail.party.client;
|
||||||
|
|
||||||
|
import com.threerings.cocktail.cher.client.Client;
|
||||||
|
|
||||||
public class LocationManager
|
public class LocationManager
|
||||||
{
|
{
|
||||||
|
public LocationManager (Client client)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
//
|
//
|
||||||
// $Id: Log.java,v 1.3 2001/05/30 23:58:31 mdb Exp $
|
// $Id: Log.java,v 1.4 2001/07/20 23:23:50 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.cher;
|
package com.threerings.cocktail.cher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A placeholder class that contains a reference to the log object used by
|
* A placeholder class that contains a reference to the log object used by
|
||||||
* the Spine package.
|
* the Cher services.
|
||||||
*/
|
*/
|
||||||
public class Log
|
public class Log
|
||||||
{
|
{
|
||||||
public static com.samskivert.util.Log log =
|
public static com.samskivert.util.Log log =
|
||||||
new com.samskivert.util.Log("cher");
|
new com.samskivert.util.Log("cocktail.cher");
|
||||||
|
|
||||||
/** Convenience function. */
|
/** Convenience function. */
|
||||||
public static void debug (String message)
|
public static void debug (String message)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: PresentsContext.java,v 1.1 2001/07/20 19:49:06 mdb Exp $
|
// $Id: PresentsContext.java,v 1.2 2001/07/20 23:23:50 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.cher.util;
|
package com.threerings.cocktail.cher.util;
|
||||||
|
|
||||||
@@ -17,5 +17,5 @@ public interface CherContext extends Context
|
|||||||
/**
|
/**
|
||||||
* Returns a reference to the distributed object manager.
|
* Returns a reference to the distributed object manager.
|
||||||
*/
|
*/
|
||||||
public Client getDObjectManager ();
|
public DObjectManager getDObjectManager ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
//
|
||||||
|
// $Id: TestClient.java,v 1.1 2001/07/20 23:23:50 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.cocktail.party.client.test;
|
||||||
|
|
||||||
|
import com.samskivert.util.Config;
|
||||||
|
import com.samskivert.util.Queue;
|
||||||
|
|
||||||
|
import com.threerings.cocktail.cher.client.*;
|
||||||
|
import com.threerings.cocktail.cher.dobj.DObjectManager;
|
||||||
|
import com.threerings.cocktail.cher.net.*;
|
||||||
|
|
||||||
|
import com.threerings.cocktail.party.Log;
|
||||||
|
import com.threerings.cocktail.party.client.LocationManager;
|
||||||
|
import com.threerings.cocktail.party.util.PartyContext;
|
||||||
|
|
||||||
|
public class TestClient
|
||||||
|
implements Client.Invoker, ClientObserver
|
||||||
|
{
|
||||||
|
public TestClient (Credentials creds)
|
||||||
|
{
|
||||||
|
// create the handles on our various services
|
||||||
|
_config = new Config();
|
||||||
|
_client = new Client(creds, this);
|
||||||
|
_locmgr = new LocationManager(_client);
|
||||||
|
|
||||||
|
// create our context
|
||||||
|
_ctx = new PartyContextImpl();
|
||||||
|
|
||||||
|
// we want to know about logon/logoff
|
||||||
|
_client.addObserver(this);
|
||||||
|
|
||||||
|
// for test purposes, hardcode the server info
|
||||||
|
_client.setServer("localhost", 4007);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run ()
|
||||||
|
{
|
||||||
|
// log on
|
||||||
|
_client.logon();
|
||||||
|
|
||||||
|
// loop over our queue, running the runnables
|
||||||
|
while (true) {
|
||||||
|
Runnable run = (Runnable)_queue.get();
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invokeLater (Runnable run)
|
||||||
|
{
|
||||||
|
// queue it on up
|
||||||
|
_queue.append(run);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clientDidLogon (Client client)
|
||||||
|
{
|
||||||
|
Log.info("Client did logon [client=" + client + "].");
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clientDidLogoff (Client client)
|
||||||
|
{
|
||||||
|
Log.info("Client did logoff [client=" + client + "].");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main (String[] args)
|
||||||
|
{
|
||||||
|
UsernamePasswordCreds creds =
|
||||||
|
new UsernamePasswordCreds("test", "test");
|
||||||
|
// create our test client
|
||||||
|
TestClient tclient = new TestClient(creds);
|
||||||
|
// start it running
|
||||||
|
tclient.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class PartyContextImpl implements PartyContext
|
||||||
|
{
|
||||||
|
public Config getConfig ()
|
||||||
|
{
|
||||||
|
return _config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Client getClient ()
|
||||||
|
{
|
||||||
|
return _client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DObjectManager getDObjectManager ()
|
||||||
|
{
|
||||||
|
return _client.getDObjectManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocationManager getLocationManager ()
|
||||||
|
{
|
||||||
|
return _locmgr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Config _config;
|
||||||
|
protected Client _client;
|
||||||
|
protected LocationManager _locmgr;
|
||||||
|
protected PartyContext _ctx;
|
||||||
|
|
||||||
|
protected Queue _queue = new Queue();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user