Revamped the basic Presents client to support attempts to connect to the server

on multiple ports, falling back from one to the next as appropriate.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4158 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-05-30 22:12:15 +00:00
parent a3dfc741c6
commit 77adfc15ec
18 changed files with 128 additions and 112 deletions
@@ -50,8 +50,8 @@ public class JabberApp
_client.init(_frame);
}
public void run (String server, int port, String username, String password,
int roomId)
public void run (
String server, String username, String password, int roomId)
{
// position everything and show the frame
_frame.setSize(800, 600);
@@ -62,8 +62,8 @@ public class JabberApp
Client client = _client.getContext().getClient();
// pass them on to the client
Log.info("Using [server=" + server + ", port=" + port + "].");
client.setServer(server, port);
Log.info("Using [server=" + server + "].");
client.setServer(server, Client.DEFAULT_SERVER_PORTS);
// configure the client with some credentials and logon
if (username != null && password != null) {
@@ -80,18 +80,8 @@ public class JabberApp
if (args.length > 0) {
server = args[0];
}
int port = Client.DEFAULT_SERVER_PORT;
if (args.length > 1) {
try {
port = Integer.parseInt(args[1]);
} catch (NumberFormatException nfe) {
Log.warning("Invalid port specification '" + args[1] + "'.");
}
}
String username = (args.length > 2) ? args[2] : null;
String password = (args.length > 3) ? args[3] : null;
String username = (args.length > 1) ? args[1] : null;
String password = (args.length > 2) ? args[2] : null;
int roomId = 2;
if (args.length > 4) {
try {
@@ -111,7 +101,7 @@ public class JabberApp
}
// and run it
app.run(server, port, username, password, roomId);
app.run(server, username, password, roomId);
}
protected JabberClient _client;
@@ -63,7 +63,7 @@ public class JabberClient
createContextServices();
// for test purposes, hardcode the server info
_client.setServer("localhost", Client.DEFAULT_SERVER_PORT);
_client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
_client.addClientObserver(this);
// keep this for later
@@ -55,7 +55,7 @@ public class TestClient
_client.addClientObserver(this);
// for test purposes, hardcode the server info
_client.setServer("localhost", Client.DEFAULT_SERVER_PORT);
_client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
}
public void run ()
@@ -95,13 +95,13 @@ public class JabberApp extends JmeApp
return true;
}
public void run (String server, int port, String username, String password)
public void run (String server, String username, String password)
{
Client client = _client.getContext().getClient();
// pass them on to the client
Log.info("Using [server=" + server + ", port=" + port + "].");
client.setServer(server, port);
Log.info("Using [server=" + server + ".");
client.setServer(server, Client.DEFAULT_SERVER_PORTS);
// configure the client with some credentials and logon
if (username != null && password != null) {
@@ -136,15 +136,6 @@ public class JabberApp extends JmeApp
server = args[0];
}
int port = Client.DEFAULT_SERVER_PORT;
if (args.length > 1) {
try {
port = Integer.parseInt(args[1]);
} catch (NumberFormatException nfe) {
Log.warning("Invalid port specification '" + args[1] + "'.");
}
}
// load up the default BUI stylesheet
try {
InputStream stin = JabberApp.class.getClassLoader().
@@ -157,12 +148,12 @@ public class JabberApp extends JmeApp
System.exit(-1);
}
String username = (args.length > 2) ? args[2] : null;
String password = (args.length > 3) ? args[3] : null;
String username = (args.length > 1) ? args[1] : null;
String password = (args.length > 2) ? args[2] : null;
JabberApp app = new JabberApp();
app.init();
app.run(server, port, username, password);
app.run(server, username, password);
}
protected JabberClient _client;
@@ -67,7 +67,7 @@ public class JabberClient
createContextServices(app);
// for test purposes, hardcode the server info
_client.setServer("localhost", Client.DEFAULT_SERVER_PORT);
_client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
_client.addClientObserver(this);
}
@@ -154,7 +154,7 @@ public class TestClient
Client client = new Client(creds, tclient);
tclient.setClient(client);
client.addClientObserver(tclient);
client.setServer("localhost", Client.DEFAULT_SERVER_PORT);
client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
client.logon();
// start up our event processing loop
tclient.run();