frame.setSize(800, 600);
SwingUtil.centerWindow(frame);
frame.setVisible(true);
// start up the client
Client client = _client.getParlorContext().getClient();
log.info("Connecting to localhost.");
client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
// we want to exit when we logged off or failed to log on
client.addClientObserver(new ClientAdapter() {
@Override
public void clientFailedToLogon (Client c, Exception cause) {
log.info("Client failed to logon: " + cause);
System.exit(0);
}
@Override
public void clientDidLogoff (Client c) {
System.exit(0);
}
});
// configure the client with some credentials and logon
String username = System.getProperty("username");
if (username == null) {
username =
"bob" + ((int)(Math.random() * Integer.MAX_VALUE) % 500);
}
String password = System.getProperty("password");
if (password == null) {
password = "test";
}
// create and set our credentials
client.setCredentials(
new UsernamePasswordCreds(new Name(username), password));
// this is a bit of a hack, but we need to give the server long
// enough to fully initialize and start listening on its socket
// before we try to logon; there's no good way for this otherwise