Minor cleanups; added PlaceManager to MessageHandler callback.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@773 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-14 00:11:18 +00:00
parent 2c1e5c1ba5
commit 6e962013a9
5 changed files with 24 additions and 16 deletions
@@ -1,5 +1,5 @@
// //
// $Id: ChatMessageHandler.java,v 1.4 2001/10/18 20:51:59 mdb Exp $ // $Id: ChatMessageHandler.java,v 1.5 2001/12/14 00:11:17 mdb Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat;
@@ -17,8 +17,10 @@ import com.threerings.crowd.server.PlaceManager;
*/ */
public class ChatMessageHandler implements PlaceManager.MessageHandler public class ChatMessageHandler implements PlaceManager.MessageHandler
{ {
/** Handles {@link ChatCodes#SPEAK_REQUEST} messages. */ /**
public void handleEvent (MessageEvent event) * Handles {@link ChatCodes#SPEAK_REQUEST} messages.
*/
public void handleEvent (MessageEvent event, PlaceManager pmgr)
{ {
// presently we do no ratification of chat messages, so we just // presently we do no ratification of chat messages, so we just
// generate a chat notification with the message and name of the // generate a chat notification with the message and name of the
@@ -1,5 +1,5 @@
// //
// $Id: OccupantInfo.java,v 1.3 2001/10/11 04:07:51 mdb Exp $ // $Id: OccupantInfo.java,v 1.4 2001/12/14 00:11:17 mdb Exp $
package com.threerings.crowd.data; package com.threerings.crowd.data;
@@ -64,11 +64,9 @@ public class OccupantInfo implements DSet.Element
*/ */
public String toString () public String toString ()
{ {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer("[");
buf.append("[");
toString(buf); toString(buf);
buf.append("]"); return buf.append("]").toString();
return buf.toString();
} }
/** /**
@@ -1,11 +1,12 @@
// //
// $Id: PlaceManager.java,v 1.24 2001/11/18 04:27:56 mdb Exp $ // $Id: PlaceManager.java,v 1.25 2001/12/14 00:11:17 mdb Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
import java.util.HashMap; import java.util.HashMap;
import java.util.Properties; import java.util.Properties;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.MessageEvent; import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.dobj.MessageListener; import com.threerings.presents.dobj.MessageListener;
import com.threerings.presents.dobj.ObjectAddedEvent; import com.threerings.presents.dobj.ObjectAddedEvent;
@@ -50,8 +51,10 @@ public class PlaceManager
* Invokes this message handler on the supplied event. * Invokes this message handler on the supplied event.
* *
* @param event the message event received. * @param event the message event received.
* @param pmgr the place manager for which the message is being
* handled.
*/ */
public void handleEvent (MessageEvent event); public void handleEvent (MessageEvent event, PlaceManager pmgr);
} }
/** /**
@@ -91,10 +94,12 @@ public class PlaceManager
/** /**
* Called by the place registry after creating this place manager. * Called by the place registry after creating this place manager.
*/ */
public void init (PlaceRegistry registry, PlaceConfig config) public void init (
PlaceRegistry registry, PlaceConfig config, DObjectManager omgr)
{ {
_registry = registry; _registry = registry;
_config = config; _config = config;
_omgr = omgr;
// let derived classes do initialization stuff // let derived classes do initialization stuff
didInit(); didInit();
@@ -279,7 +284,7 @@ public class PlaceManager
handler = (MessageHandler)_msghandlers.get(event.getName()); handler = (MessageHandler)_msghandlers.get(event.getName());
} }
if (handler != null) { if (handler != null) {
handler.handleEvent(event); handler.handleEvent(event, this);
} }
} }
@@ -351,6 +356,9 @@ public class PlaceManager
buf.append(", config=").append(_config); buf.append(", config=").append(_config);
} }
/** A distributed object manager for doing dobj stuff. */
protected DObjectManager _omgr;
/** A reference to the place object that we manage. */ /** A reference to the place object that we manage. */
protected PlaceObject _plobj; protected PlaceObject _plobj;
@@ -1,5 +1,5 @@
// //
// $Id: PlaceRegistry.java,v 1.17 2001/12/04 01:02:59 mdb Exp $ // $Id: PlaceRegistry.java,v 1.18 2001/12/14 00:11:17 mdb Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -89,7 +89,7 @@ public class PlaceRegistry
// create a place manager for this place // create a place manager for this place
PlaceManager pmgr = (PlaceManager)pmgrClass.newInstance(); PlaceManager pmgr = (PlaceManager)pmgrClass.newInstance();
// let the pmgr know about us and its configuration // let the pmgr know about us and its configuration
pmgr.init(this, config); pmgr.init(this, config, _omgr);
// stick the manager on the creation queue because we know // stick the manager on the creation queue because we know
// we'll get our calls to objectAvailable()/requestFailed() in // we'll get our calls to objectAvailable()/requestFailed() in
@@ -1,5 +1,5 @@
// //
// $Id: GameManager.java,v 1.16 2001/11/07 10:44:02 mdb Exp $ // $Id: GameManager.java,v 1.17 2001/12/14 00:11:18 mdb Exp $
package com.threerings.parlor.game; package com.threerings.parlor.game;
@@ -211,7 +211,7 @@ public class GameManager
/** Handles player ready notifications. */ /** Handles player ready notifications. */
protected class PlayerReadyHandler implements MessageHandler protected class PlayerReadyHandler implements MessageHandler
{ {
public void handleEvent (MessageEvent event) public void handleEvent (MessageEvent event, PlaceManager pmgr)
{ {
int cloid = event.getSourceOid(); int cloid = event.getSourceOid();
BodyObject body = (BodyObject) BodyObject body = (BodyObject)