Further wired up the client side of the distributed object system. Removed
the facilities for fetching (without subscribing to) an object. This is done extremely rarely and the user might as well just subscribe and immediately unsubscribe because the dichotomy between fetching and subscribing just served to overly complicate the internals for no good reason. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@30 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientManager.java,v 1.4 2001/06/05 22:50:08 mdb Exp $
|
||||
// $Id: ClientManager.java,v 1.5 2001/06/09 23:39:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -56,6 +56,9 @@ public class ClientManager implements ConnectionObserver
|
||||
client = new Client(this, username, conn);
|
||||
_usermap.put(username, conn);
|
||||
}
|
||||
|
||||
// map this connection to this client
|
||||
_conmap.put(conn, client);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +74,7 @@ public class ClientManager implements ConnectionObserver
|
||||
void connectionFailed (Connection conn, IOException fault)
|
||||
{
|
||||
// remove the client from the connection map
|
||||
Client client = (Client)_connmap.remove(conn);
|
||||
Client client = (Client)_conmap.remove(conn);
|
||||
if (client != null) {
|
||||
Log.info("Unmapped failed client [client=" + client +
|
||||
", conn=" + conn + ", fault=" + fault + "].");
|
||||
@@ -92,7 +95,7 @@ public class ClientManager implements ConnectionObserver
|
||||
public synchronized void connectionClosed (Connection conn)
|
||||
{
|
||||
// remove the client from the connection map
|
||||
Client client = (Client)_connmap.remove(conn);
|
||||
Client client = (Client)_conmap.remove(conn);
|
||||
if (client != null) {
|
||||
Log.info("Unmapped client [client=" + client +
|
||||
", conn=" + conn + "].");
|
||||
@@ -125,5 +128,5 @@ public class ClientManager implements ConnectionObserver
|
||||
}
|
||||
|
||||
protected HashMap _usermap = new HashMap();
|
||||
protected HashMap _connmap = new HashMap();
|
||||
protected HashMap _conmap = new HashMap();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsClient.java,v 1.2 2001/06/05 22:44:31 mdb Exp $
|
||||
// $Id: PresentsClient.java,v 1.3 2001/06/09 23:39:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -192,21 +192,6 @@ public class Client implements Subscriber, MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes fetch requests.
|
||||
*/
|
||||
protected static class FetchDispatcher implements MessageDispatcher
|
||||
{
|
||||
public void dispatch (Client client, UpstreamMessage msg)
|
||||
{
|
||||
FetchRequest req = (FetchRequest)msg;
|
||||
Log.info("Fetching [client=" + client +
|
||||
", oid=" + req.getOid() + "].");
|
||||
// forward the fetch request to the omgr for processing
|
||||
CherServer.omgr.fetchObject(req.getOid(), client);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes unsubscribe requests.
|
||||
*/
|
||||
@@ -287,7 +272,6 @@ public class Client implements Subscriber, MessageHandler
|
||||
// register our message dispatchers
|
||||
static {
|
||||
_disps.put(SubscribeRequest.class, new SubscribeDispatcher());
|
||||
_disps.put(FetchRequest.class, new FetchDispatcher());
|
||||
_disps.put(UnsubscribeRequest.class, new UnsubscribeDispatcher());
|
||||
_disps.put(ForwardEventRequest.class, new ForwardEventDispatcher());
|
||||
_disps.put(PingRequest.class, new PingDispatcher());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsDObjectMgr.java,v 1.4 2001/06/05 22:44:31 mdb Exp $
|
||||
// $Id: PresentsDObjectMgr.java,v 1.5 2001/06/09 23:39:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -32,7 +32,8 @@ public class CherDObjectMgr implements DObjectManager
|
||||
// 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);
|
||||
dummy.setOid(0);
|
||||
dummy.setManager(this);
|
||||
_objects.put(0, new DObject());
|
||||
}
|
||||
|
||||
@@ -52,14 +53,6 @@ public class CherDObjectMgr implements DObjectManager
|
||||
AccessObjectEvent.SUBSCRIBE));
|
||||
}
|
||||
|
||||
// inherit documentation from the interface
|
||||
public void fetchObject (int oid, Subscriber target)
|
||||
{
|
||||
// queue up an access object event
|
||||
postEvent(new AccessObjectEvent(oid, target,
|
||||
AccessObjectEvent.FETCH));
|
||||
}
|
||||
|
||||
// inherit documentation from the interface
|
||||
public void unsubscribeFromObject (int oid, Subscriber target)
|
||||
{
|
||||
@@ -192,10 +185,14 @@ public class CherDObjectMgr implements DObjectManager
|
||||
DObject obj = (DObject)_class.newInstance();
|
||||
|
||||
// initialize this object
|
||||
obj.init(oid, CherDObjectMgr.this);
|
||||
obj.setOid(oid);
|
||||
obj.setManager(CherDObjectMgr.this);
|
||||
// insert it into the table
|
||||
_objects.put(oid, obj);
|
||||
|
||||
Log.info("Created object [oid=" + oid +
|
||||
", obj=" + obj + "].");
|
||||
|
||||
if (_target != null) {
|
||||
// add the subscriber to this object's subscriber list
|
||||
// if they requested it
|
||||
@@ -239,8 +236,7 @@ public class CherDObjectMgr implements DObjectManager
|
||||
protected class AccessObjectEvent extends DEvent
|
||||
{
|
||||
public static final int SUBSCRIBE = 0;
|
||||
public static final int FETCH = 1;
|
||||
public static final int UNSUBSCRIBE = 2;
|
||||
public static final int UNSUBSCRIBE = 1;
|
||||
|
||||
public AccessObjectEvent (int oid, Subscriber target,
|
||||
int action)
|
||||
@@ -278,10 +274,8 @@ public class CherDObjectMgr implements DObjectManager
|
||||
return false;
|
||||
}
|
||||
|
||||
// if they wanted to subscribe, do so
|
||||
if (_action == SUBSCRIBE) {
|
||||
obj.addSubscriber(_target);
|
||||
}
|
||||
// subscribe 'em
|
||||
obj.addSubscriber(_target);
|
||||
|
||||
// let them know that things are groovy
|
||||
_target.objectAvailable(obj);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsServer.java,v 1.4 2001/06/01 22:12:03 mdb Exp $
|
||||
// $Id: PresentsServer.java,v 1.5 2001/06/09 23:39:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.server;
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.threerings.cocktail.cher.dobj.DObjectManager;
|
||||
import com.threerings.cocktail.cher.server.net.AuthManager;
|
||||
import com.threerings.cocktail.cher.server.net.ConnectionManager;
|
||||
|
||||
import com.threerings.cocktail.cher.server.test.TestObject;
|
||||
|
||||
/**
|
||||
* The cher server provides a central point of access to the various
|
||||
* facilities that make up the cher layer of the system.
|
||||
@@ -41,6 +43,9 @@ public class CherServer
|
||||
// create our distributed object manager
|
||||
omgr = new CherDObjectMgr();
|
||||
|
||||
// create an object for testing
|
||||
omgr.createObject(TestObject.class, null, false);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to initialize server.");
|
||||
Log.logStackTrace(e);
|
||||
|
||||
Reference in New Issue
Block a user