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
This commit is contained in:
@@ -153,6 +153,10 @@ public class ChatDirector extends BasicDirector
|
|||||||
_ctx.getLocationDirector().addLocationObserver(this);
|
_ctx.getLocationDirector().addLocationObserver(this);
|
||||||
|
|
||||||
// register our default chat handlers
|
// 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);
|
MessageBundle msg = _msgmgr.getBundle(_bundle);
|
||||||
registerCommandHandler(msg, "help", new HelpHandler());
|
registerCommandHandler(msg, "help", new HelpHandler());
|
||||||
registerCommandHandler(msg, "clear", new ClearHandler());
|
registerCommandHandler(msg, "clear", new ClearHandler());
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ public class ChatPanel
|
|||||||
|
|
||||||
// create our chat director and register ourselves with it
|
// create our chat director and register ourselves with it
|
||||||
_chatdtr = new ChatDirector(_ctx, null, null);
|
_chatdtr = new ChatDirector(_ctx, null, null);
|
||||||
|
// XXX - the line above royally borks things because it sends
|
||||||
|
// null, null downstream.
|
||||||
_chatdtr.addChatDisplay(this);
|
_chatdtr.addChatDisplay(this);
|
||||||
|
|
||||||
// register as an occupant observer
|
// register as an occupant observer
|
||||||
|
|||||||
@@ -50,13 +50,15 @@ public class JabberApp
|
|||||||
_client.init(_frame);
|
_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
|
// position everything and show the frame
|
||||||
_frame.setSize(800, 600);
|
_frame.setSize(800, 600);
|
||||||
SwingUtil.centerWindow(_frame);
|
SwingUtil.centerWindow(_frame);
|
||||||
_frame.setVisible(true);
|
_frame.setVisible(true);
|
||||||
|
|
||||||
|
_client.setRoom(roomId);
|
||||||
Client client = _client.getContext().getClient();
|
Client client = _client.getContext().getClient();
|
||||||
|
|
||||||
// pass them on to the client
|
// pass them on to the client
|
||||||
@@ -90,6 +92,14 @@ public class JabberApp
|
|||||||
|
|
||||||
String username = (args.length > 2) ? args[2] : null;
|
String username = (args.length > 2) ? args[2] : null;
|
||||||
String password = (args.length > 3) ? args[3] : 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();
|
JabberApp app = new JabberApp();
|
||||||
try {
|
try {
|
||||||
@@ -101,7 +111,7 @@ public class JabberApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and run it
|
// and run it
|
||||||
app.run(server, port, username, password);
|
app.run(server, port, username, password, roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JabberClient _client;
|
protected JabberClient _client;
|
||||||
|
|||||||
@@ -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
|
* Returns a reference to the context in effect for this client. This
|
||||||
* reference is valid for the lifetime of the application.
|
* 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
|
// place on the whole server; a normal client would either issue
|
||||||
// an invocation service request at this point or look at
|
// an invocation service request at this point or look at
|
||||||
// something in the BootstrapData to figure out what to do
|
// something in the BootstrapData to figure out what to do
|
||||||
_ctx.getLocationDirector().moveTo(2);
|
_ctx.getLocationDirector().moveTo(_roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface SessionObserver
|
// documentation inherited from interface SessionObserver
|
||||||
@@ -231,6 +239,7 @@ public class JabberClient
|
|||||||
protected OccupantDirector _occdir;
|
protected OccupantDirector _occdir;
|
||||||
protected ChatDirector _chatdir;
|
protected ChatDirector _chatdir;
|
||||||
protected MessageManager _msgmgr;
|
protected MessageManager _msgmgr;
|
||||||
|
protected int _roomId;
|
||||||
|
|
||||||
/** The prefix prepended to localization bundle names before looking
|
/** The prefix prepended to localization bundle names before looking
|
||||||
* them up in the classpath. */
|
* them up in the classpath. */
|
||||||
|
|||||||
Reference in New Issue
Block a user