From eada0b7f502bb0493f78220e7fa29139aeba5b59 Mon Sep 17 00:00:00 2001 From: Elizabeth Fong Date: Tue, 25 Oct 2005 11:13:51 +0000 Subject: [PATCH] r58@sally: elizabeth | 2005-10-25 03:59:59 -0700 Changed things around a bit to have the cheesy JabberChat run out of the box: * ChatDirector no longer freaks out when given null message bundles/managers. * MiCasa's ChatPanel is marked with a TODO item to stop passing in null messagebundles and messagemanagers to ChatDirector. * JabberApp and JabberClient have been adjusted to allow the user to specify which chatroom to join from the command line; I plan to implement this using BootstrapData when time permits. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3741 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/crowd/chat/client/ChatDirector.java | 4 ++++ .../com/threerings/micasa/client/ChatPanel.java | 2 ++ .../com/threerings/crowd/client/JabberApp.java | 14 ++++++++++++-- .../com/threerings/crowd/client/JabberClient.java | 11 ++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index f2f57a9e4..6dfe5d625 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -153,6 +153,10 @@ public class ChatDirector extends BasicDirector _ctx.getLocationDirector().addLocationObserver(this); // register our default chat handlers + if (_bundle == null || _msgmgr == null) { + Log.warning("Null bundle or message manager given to ChatDirector"); + return; + } MessageBundle msg = _msgmgr.getBundle(_bundle); registerCommandHandler(msg, "help", new HelpHandler()); registerCommandHandler(msg, "clear", new ClearHandler()); diff --git a/src/java/com/threerings/micasa/client/ChatPanel.java b/src/java/com/threerings/micasa/client/ChatPanel.java index 9ed9fe7c1..ac3b3b14d 100644 --- a/src/java/com/threerings/micasa/client/ChatPanel.java +++ b/src/java/com/threerings/micasa/client/ChatPanel.java @@ -78,6 +78,8 @@ public class ChatPanel // create our chat director and register ourselves with it _chatdtr = new ChatDirector(_ctx, null, null); + // XXX - the line above royally borks things because it sends + // null, null downstream. _chatdtr.addChatDisplay(this); // register as an occupant observer diff --git a/tests/src/java/com/threerings/crowd/client/JabberApp.java b/tests/src/java/com/threerings/crowd/client/JabberApp.java index 2ea9cc86b..a98b04a81 100644 --- a/tests/src/java/com/threerings/crowd/client/JabberApp.java +++ b/tests/src/java/com/threerings/crowd/client/JabberApp.java @@ -50,13 +50,15 @@ public class JabberApp _client.init(_frame); } - public void run (String server, int port, String username, String password) + public void run (String server, int port, String username, String password, + int roomId) { // position everything and show the frame _frame.setSize(800, 600); SwingUtil.centerWindow(_frame); _frame.setVisible(true); + _client.setRoom(roomId); Client client = _client.getContext().getClient(); // pass them on to the client @@ -90,6 +92,14 @@ public class JabberApp String username = (args.length > 2) ? args[2] : null; String password = (args.length > 3) ? args[3] : null; + int roomId = 2; + if (args.length > 4) { + try { + roomId = Integer.parseInt(args[4]); + } catch (NumberFormatException e) { + // so what? + } + } JabberApp app = new JabberApp(); try { @@ -101,7 +111,7 @@ public class JabberApp } // and run it - app.run(server, port, username, password); + app.run(server, port, username, password, roomId); } protected JabberClient _client; diff --git a/tests/src/java/com/threerings/crowd/client/JabberClient.java b/tests/src/java/com/threerings/crowd/client/JabberClient.java index f8aca66fd..5ffc171d5 100644 --- a/tests/src/java/com/threerings/crowd/client/JabberClient.java +++ b/tests/src/java/com/threerings/crowd/client/JabberClient.java @@ -83,6 +83,14 @@ public class JabberClient }); } + /** + * Sets the roomId to which we will connect upon logon. + */ + public void setRoom (int roomId) + { + _roomId = roomId; + } + /** * Returns a reference to the context in effect for this client. This * reference is valid for the lifetime of the application. @@ -100,7 +108,7 @@ public class JabberClient // place on the whole server; a normal client would either issue // an invocation service request at this point or look at // something in the BootstrapData to figure out what to do - _ctx.getLocationDirector().moveTo(2); + _ctx.getLocationDirector().moveTo(_roomId); } // documentation inherited from interface SessionObserver @@ -231,6 +239,7 @@ public class JabberClient protected OccupantDirector _occdir; protected ChatDirector _chatdir; protected MessageManager _msgmgr; + protected int _roomId; /** The prefix prepended to localization bundle names before looking * them up in the classpath. */