From 0bb157aedfd00f122931ceb0ba6dab53b5e7af19 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 25 Oct 2006 17:10:30 +0000 Subject: [PATCH] When running in local mode we want to properly tag all events originating on the client with the proper source oid. Normally this happens when the client's event is received over the network but in local mode events never go over the network and thus all appear to have originated on the "server". git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4435 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/LocalDObjectMgr.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/java/com/threerings/presents/server/LocalDObjectMgr.java b/src/java/com/threerings/presents/server/LocalDObjectMgr.java index 39a2a787e..cb6d3ae6e 100644 --- a/src/java/com/threerings/presents/server/LocalDObjectMgr.java +++ b/src/java/com/threerings/presents/server/LocalDObjectMgr.java @@ -24,6 +24,9 @@ package com.threerings.presents.server; import java.awt.EventQueue; import com.threerings.presents.dobj.DEvent; +import com.threerings.presents.dobj.DObject; +import com.threerings.presents.dobj.DObjectManager; +import com.threerings.presents.dobj.Subscriber; /** * A special version of the distributed object manager, modified to @@ -33,6 +36,37 @@ import com.threerings.presents.dobj.DEvent; */ public class LocalDObjectMgr extends PresentsDObjectMgr { + /** + * Creates a {@link DObjectManager} that posts directly to this local + * object manager, but first sets the source oid of all events to properly + * identify them with the supplied client oid. Normally this oid setting + * happens when an event is received on the server over the network, but in + * local mode we have to do it by hand. + */ + public DObjectManager getClientDObjectMgr (final int clientOid) + { + return new DObjectManager() { + public boolean isManager (DObject object) { + return LocalDObjectMgr.this.isManager(object); + } + public void subscribeToObject ( + int oid, Subscriber target) { + LocalDObjectMgr.this.subscribeToObject(oid, target); + } + public void unsubscribeFromObject ( + int oid, Subscriber target) { + LocalDObjectMgr.this.unsubscribeFromObject(oid, target); + } + public void postEvent (DEvent event) { + event.setSourceOid(clientOid); + LocalDObjectMgr.this.postEvent(event); + } + public void removedLastSubscriber (DObject obj, boolean deathWish) { + LocalDObjectMgr.this.removedLastSubscriber(obj, deathWish); + } + }; + } + // documentation inherited public synchronized boolean isDispatchThread () {