More juicy goodness. Event dispatch seems to work now.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@20 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsDObjectMgr.java,v 1.1 2001/06/01 19:56:13 mdb Exp $
|
||||
// $Id: PresentsDObjectMgr.java,v 1.2 2001/06/01 20:35:39 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -24,6 +24,18 @@ import com.threerings.cocktail.cher.util.IntMap;
|
||||
*/
|
||||
public class CherDObjectMgr implements DObjectManager
|
||||
{
|
||||
/**
|
||||
* Creates the dobjmgr and prepares it for operation.
|
||||
*/
|
||||
public CherDObjectMgr ()
|
||||
{
|
||||
// we create a dummy object to live as oid zero and we'll use that
|
||||
// for some internal event trickery
|
||||
DObject dummy = new DObject();
|
||||
dummy.init(0, this);
|
||||
_objects.put(0, new DObject());
|
||||
}
|
||||
|
||||
// inherit documentation from the interface
|
||||
public void createObject (Class dclass, Subscriber target,
|
||||
boolean subscribe)
|
||||
@@ -53,18 +65,6 @@ public class CherDObjectMgr implements DObjectManager
|
||||
_evqueue.append(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the dobjmgr and prepares it for operation.
|
||||
*/
|
||||
public void init ()
|
||||
{
|
||||
// we create a dummy object to live as oid zero and we'll use that
|
||||
// for some internal event trickery
|
||||
DObject dummy = new DObject();
|
||||
dummy.init(0, this);
|
||||
_objects.put(0, new DObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the dobjmgr event loop until it is requested to exit. This
|
||||
* should be called from the main application thread.
|
||||
@@ -104,6 +104,7 @@ public class CherDObjectMgr implements DObjectManager
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failure applying event [event=" + event +
|
||||
", target=" + target + ", error=" + e + "].");
|
||||
Log.logStackTrace(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -128,9 +129,10 @@ public class CherDObjectMgr implements DObjectManager
|
||||
public void shutdown ()
|
||||
{
|
||||
_running = false;
|
||||
|
||||
// stick a bogus object on the event queue to ensure that the mgr
|
||||
// wakes up and smells the coffee
|
||||
_evqueue.append(this);
|
||||
_evqueue.append(new ShutdownEvent());
|
||||
}
|
||||
|
||||
protected synchronized boolean isRunning ()
|
||||
@@ -269,4 +271,19 @@ public class CherDObjectMgr implements DObjectManager
|
||||
protected Subscriber _target;
|
||||
protected boolean _subscribe;
|
||||
}
|
||||
|
||||
protected class ShutdownEvent extends DEvent
|
||||
{
|
||||
public ShutdownEvent ()
|
||||
{
|
||||
super(0); // target the bogus object
|
||||
}
|
||||
|
||||
public boolean applyToObject (DObject target)
|
||||
throws ObjectAccessException
|
||||
{
|
||||
// nothing doing!
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//
|
||||
// $Id: PresentsServer.java,v 1.2 2001/05/30 23:58:31 mdb Exp $
|
||||
// $Id: PresentsServer.java,v 1.3 2001/06/01 20:35:39 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
import com.threerings.cocktail.cher.Log;
|
||||
import com.threerings.cocktail.cher.dobj.DObjectManager;
|
||||
import com.threerings.cocktail.cher.server.net.AuthManager;
|
||||
import com.threerings.cocktail.cher.server.net.ConnectionManager;
|
||||
|
||||
@@ -19,6 +20,9 @@ public class CherServer
|
||||
/** The manager of network connections. */
|
||||
public static ConnectionManager cmgr;
|
||||
|
||||
/** The distributed object manager. */
|
||||
public static DObjectManager omgr;
|
||||
|
||||
/**
|
||||
* Initializes all of the server services and prepares for operation.
|
||||
*/
|
||||
@@ -29,6 +33,8 @@ public class CherServer
|
||||
authmgr = new AuthManager(new DummyAuthenticator());
|
||||
// create our connection manager
|
||||
cmgr = new ConnectionManager(authmgr);
|
||||
// create our distributed object manager
|
||||
omgr = new CherDObjectMgr();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to initialize server.");
|
||||
@@ -40,25 +46,19 @@ public class CherServer
|
||||
* Starts up all of the server services and enters the main server
|
||||
* event loop.
|
||||
*/
|
||||
public static void start ()
|
||||
public static void run ()
|
||||
{
|
||||
// start up the auth manager
|
||||
authmgr.start();
|
||||
// start up the connection manager
|
||||
cmgr.start();
|
||||
|
||||
// for now, just block because we've nothing to do
|
||||
try {
|
||||
synchronized (CherServer.class) {
|
||||
CherServer.class.wait();
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
// invoke the dobjmgr event loop
|
||||
((CherDObjectMgr)omgr).run();
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
init();
|
||||
start();
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user