Revamped logon and logoff handling so that the driver is responsible for
either exiting or closing the window when we logoff rather than the client or the client controller which don't know if we're in an applet or an application or something else. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@569 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientController.java,v 1.9 2001/10/25 23:02:57 mdb Exp $
|
||||
// $Id: ClientController.java,v 1.10 2001/10/25 23:21:32 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -126,7 +126,6 @@ public class ClientController
|
||||
public void clientDidLogoff (Client client)
|
||||
{
|
||||
Log.info("Client did logoff [client=" + client + "].");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
protected MiCasaContext _ctx;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaApp.java,v 1.2 2001/10/25 23:03:29 mdb Exp $
|
||||
// $Id: MiCasaApp.java,v 1.3 2001/10/25 23:21:32 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.ClientAdapter;
|
||||
import com.threerings.presents.net.Credentials;
|
||||
import com.threerings.presents.net.UsernamePasswordCreds;
|
||||
|
||||
@@ -36,14 +37,27 @@ public class MiCasaApp
|
||||
SwingUtil.centerWindow(_frame);
|
||||
_frame.show();
|
||||
|
||||
Client client = _client.getContext().getClient();
|
||||
|
||||
// we want to exit when we logged off or failed to log on
|
||||
client.addObserver(new ClientAdapter() {
|
||||
public void clientFailedToLogon (Client c, Exception cause) {
|
||||
System.exit(0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
// create and set our credentials
|
||||
Credentials creds = new UsernamePasswordCreds(username, "test");
|
||||
Client client = _client.getContext().getClient();
|
||||
client.setCredentials(creds);
|
||||
client.logon();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaApplet.java,v 1.1 2001/10/25 23:03:48 mdb Exp $
|
||||
// $Id: MiCasaApplet.java,v 1.2 2001/10/25 23:21:32 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -7,7 +7,10 @@ import java.applet.Applet;
|
||||
import java.io.IOException;
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.ClientAdapter;
|
||||
import com.threerings.presents.net.UsernamePasswordCreds;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
|
||||
/**
|
||||
@@ -37,10 +40,20 @@ public class MiCasaApplet extends Applet
|
||||
throw new IOException("Missing authkey parameter.");
|
||||
}
|
||||
|
||||
// create our credentials
|
||||
_client.getContext().getClient().setCredentials(
|
||||
Client client = _client.getContext().getClient();
|
||||
|
||||
// create and set our credentials
|
||||
client.setCredentials(
|
||||
new UsernamePasswordCreds(username, authkey));
|
||||
|
||||
// we want to hide the client frame when we logoff
|
||||
client.addObserver(new ClientAdapter() {
|
||||
public void clientDidLogoff (Client c)
|
||||
{
|
||||
_frame.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Unable to create client.");
|
||||
Log.logStackTrace(ioe);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaClient.java,v 1.5 2001/10/18 18:39:40 mdb Exp $
|
||||
// $Id: MiCasaClient.java,v 1.6 2001/10/25 23:21:32 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -62,8 +62,6 @@ public class MiCasaClient
|
||||
// if we're logged on, log off
|
||||
if (_client.loggedOn()) {
|
||||
_client.logoff(true);
|
||||
} else {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user