From 69e84fa9fbac122d4416f83325d2aa042609ec39 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 21 Apr 2006 07:55:30 +0000 Subject: [PATCH] Added broadcast handler. Fixed bug in tell handler. Wired both up. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4041 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/chat/client/ChatDirector.java | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 0ec0dde18..c7d4a7e11 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -164,6 +164,8 @@ public class ChatDirector extends BasicDirector registerCommandHandler(msg, "speak", new SpeakHandler()); registerCommandHandler(msg, "emote", new EmoteHandler()); registerCommandHandler(msg, "think", new ThinkHandler()); + registerCommandHandler(msg, "tell", new TellHandler()); + registerCommandHandler(msg, "broadcast", new BroadcastHandler()); } /** @@ -1160,7 +1162,7 @@ public class ChatDirector extends BasicDirector } // note the command to be stored in the history history[0] = command + " "; - return requestChat(null, args, true); + return requestChat(speakSvc, args, true); } } @@ -1214,9 +1216,9 @@ public class ChatDirector extends BasicDirector while (!handle.endsWith("\"") && tok.hasMoreTokens()) { handle = handle + " " + tok.nextToken(); } - } - if (!handle.endsWith("\"")) { - return "m.usage_tell"; + if (!handle.endsWith("\"")) { + return "m.usage_tell"; + } } // now strip off everything after the handle for the message @@ -1276,6 +1278,27 @@ public class ChatDirector extends BasicDirector } } + /** Implements /broadcast. */ + protected class BroadcastHandler extends CommandHandler + { + public String handleCommand (SpeakService speakSvc, String command, + String args, String[] history) + { + if (StringUtil.isBlank(args)) { + return "m.usage_broadcast"; + } + // note the command to be stored in the history + history[0] = command + " "; + requestBroadcast(args); + return ChatCodes.SUCCESS; + } + + public boolean checkAccess (BodyObject user) + { + return user.checkAccess(ChatCodes.BROADCAST_ACCESS, null) == null; + } + } + /** Our active chat context. */ protected CrowdContext _ctx;