More support for chatting.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@160 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
//
|
||||
// $Id: PlaceManager.java,v 1.5 2001/08/01 20:37:35 mdb Exp $
|
||||
// $Id: PlaceManager.java,v 1.6 2001/08/03 02:14:41 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.party.server;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.threerings.cocktail.cher.dobj.*;
|
||||
@@ -31,7 +32,7 @@ import com.threerings.cocktail.party.data.PlaceObject;
|
||||
* protected void didShutdown ()
|
||||
* </pre>
|
||||
*
|
||||
* as well as through additions to <code>handlEvent</code>.
|
||||
* as well as through additions to <code>handleEvent</code>.
|
||||
*/
|
||||
public class PlaceManager implements Subscriber
|
||||
{
|
||||
@@ -75,6 +76,23 @@ public class PlaceManager implements Subscriber
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a particular message handler instance to be used when
|
||||
* processing message events with the specified name.
|
||||
*
|
||||
* @param name the message name of the message events that should be
|
||||
* handled by this handler.
|
||||
* @param handler the handler to be registered.
|
||||
*/
|
||||
public void registerMessageHandler (String name, MessageHandler handler)
|
||||
{
|
||||
// create our handler map if necessary
|
||||
if (_msghandlers == null) {
|
||||
_msghandlers = new HashMap();
|
||||
}
|
||||
_msghandlers.put(name, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the place object managed by this place manager.
|
||||
*/
|
||||
@@ -99,9 +117,36 @@ public class PlaceManager implements Subscriber
|
||||
*/
|
||||
public boolean handleEvent (DEvent event, DObject target)
|
||||
{
|
||||
// if this is a message event, see if we have a handler for it
|
||||
if (event instanceof MessageEvent) {
|
||||
MessageEvent mevt = (MessageEvent)event;
|
||||
MessageHandler handler = (MessageHandler)
|
||||
_msghandlers.get(mevt.getName());
|
||||
if (handler != null) {
|
||||
handler.handleEvent(mevt, (PlaceObject)target);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface used to allow the registration of standard message
|
||||
* handlers to be invoked by the place manager when particular types
|
||||
* of message events are received.
|
||||
*/
|
||||
protected static interface MessageHandler
|
||||
{
|
||||
/**
|
||||
* Invokes this message handler on the supplied event.
|
||||
*
|
||||
* @param event the message event received.
|
||||
* @param target the place object on which the message event was
|
||||
* received.
|
||||
*/
|
||||
public void handleEvent (MessageEvent event, PlaceObject target);
|
||||
}
|
||||
|
||||
/** A reference to the place object that we manage. */
|
||||
protected PlaceObject _plobj;
|
||||
|
||||
@@ -110,4 +155,7 @@ public class PlaceManager implements Subscriber
|
||||
|
||||
/** The configuration provided for this place manager. */
|
||||
protected Properties _config;
|
||||
|
||||
/** Message handlers are used to process message events. */
|
||||
protected HashMap _msghandlers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user