Let EZGames listen for user chats and pass them on as events to the user code. I'm a little uncertain if we need to do things with e.g. the bundle in the chat message object?

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@283 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Par Winzell
2007-04-27 23:32:43 +00:00
parent 7c28390287
commit fd4b2183ef
3 changed files with 114 additions and 1 deletions
@@ -66,6 +66,11 @@ import com.threerings.presents.dobj.ObjectRemovedEvent;
import com.threerings.presents.dobj.OidListListener;
import com.threerings.presents.dobj.SetListener;
import com.threerings.crowd.chat.client.ChatDisplay;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.chat.data.ChatMessage;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject;
@@ -85,7 +90,7 @@ import com.threerings.ezgame.util.EZObjectMarshaller;
*/
public class GameControlBackend
implements MessageListener, SetListener, ElementUpdateListener,
PropertySetListener
PropertySetListener, ChatDisplay
{
public var log :Log = Log.getLog(this);
@@ -99,6 +104,7 @@ public class GameControlBackend
_ezObj.addListener(this);
_ctx.getClient().getClientObject().addListener(_userListener);
_ctx.getChatDirector().addChatDisplay(this);
}
public function setSharedEvents (disp :IEventDispatcher) :void
@@ -832,6 +838,23 @@ public class GameControlBackend
event.getOldValue(), event.getIndex());
}
// from ChatDisplay
public function clear () :void
{
}
// from ChatDisplay
public function displayMessage (msg :ChatMessage, alreadyDisplayed :Boolean) :Boolean
{
if (msg is UserMessage && msg.localtype == ChatCodes.PLACE_CHAT_TYPE) {
var info :OccupantInfo = _ezObj.getOccupantInfo((msg as UserMessage).speaker);
if (info != null) {
callUserCode("userChat_v1", info.bodyOid, msg.message);
}
}
return true;
}
public function messageReceived (event :MessageEvent) :void
{
var name :String = event.getName();