Added SessionObserver which is a pared down version of ClientObserver that
only reports logon and logoff. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1117 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LocationDirector.java,v 1.17 2002/02/09 20:47:11 mdb Exp $
|
||||
// $Id: LocationDirector.java,v 1.18 2002/03/11 19:51:24 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.client;
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.threerings.crowd.util.CrowdContext;
|
||||
* before actually issuing the request.
|
||||
*/
|
||||
public class LocationDirector
|
||||
implements ClientObserver, Subscriber
|
||||
implements SessionObserver, Subscriber
|
||||
{
|
||||
/**
|
||||
* Used to recover from a moveTo request that was accepted but
|
||||
@@ -249,26 +249,11 @@ public class LocationDirector
|
||||
// we'll want to be going there straight away
|
||||
}
|
||||
|
||||
public void clientFailedToLogon (Client client, Exception cause)
|
||||
{
|
||||
// we're fair weather observers. we do nothing until logon
|
||||
// succeeds
|
||||
}
|
||||
|
||||
public void clientConnectionFailed (Client client, Exception cause)
|
||||
{
|
||||
// nothing doing
|
||||
}
|
||||
|
||||
public boolean clientWillLogoff (Client client)
|
||||
{
|
||||
// we have no objections
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clientDidLogoff (Client client)
|
||||
{
|
||||
// nothing doing
|
||||
// clear our our references
|
||||
_plobj = null;
|
||||
_placeId = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientController.java,v 1.12 2002/02/09 20:47:11 mdb Exp $
|
||||
// $Id: ClientController.java,v 1.13 2002/03/11 19:51:24 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.samskivert.swing.Controller;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.ClientObserver;
|
||||
import com.threerings.presents.client.SessionObserver;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
@@ -19,9 +19,8 @@ import com.threerings.micasa.util.MiCasaContext;
|
||||
/**
|
||||
* Responsible for top-level control of the client user interface.
|
||||
*/
|
||||
public class ClientController
|
||||
extends Controller
|
||||
implements ClientObserver
|
||||
public class ClientController extends Controller
|
||||
implements SessionObserver
|
||||
{
|
||||
/**
|
||||
* Creates a new client controller. The controller will set everything
|
||||
@@ -99,28 +98,6 @@ public class ClientController
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientFailedToLogon (Client client, Exception cause)
|
||||
{
|
||||
Log.info("Client failed to logon [client=" + client +
|
||||
", cause=" + cause + "].");
|
||||
_logonPanel.logonFailed(cause);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientConnectionFailed (Client client, Exception cause)
|
||||
{
|
||||
Log.info("Client connection failed [client=" + client +
|
||||
", cause=" + cause + "].");
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public boolean clientWillLogoff (Client client)
|
||||
{
|
||||
Log.info("Client will logoff [client=" + client + "].");
|
||||
return true;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientDidLogoff (Client client)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientController.java,v 1.4 2002/02/09 20:47:11 mdb Exp $
|
||||
// $Id: ClientController.java,v 1.5 2002/03/11 19:51:24 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.client;
|
||||
|
||||
@@ -22,9 +22,8 @@ import com.threerings.micasa.simulator.data.SimulatorInfo;
|
||||
/**
|
||||
* Responsible for top-level control of the client user interface.
|
||||
*/
|
||||
public class ClientController
|
||||
extends Controller
|
||||
implements ClientObserver
|
||||
public class ClientController extends Controller
|
||||
implements SessionObserver
|
||||
{
|
||||
/**
|
||||
* Creates a new client controller. The controller will set everything
|
||||
@@ -85,27 +84,6 @@ public class ClientController
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientFailedToLogon (Client client, Exception cause)
|
||||
{
|
||||
Log.info("Client failed to logon [client=" + client +
|
||||
", cause=" + cause + "].");
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientConnectionFailed (Client client, Exception cause)
|
||||
{
|
||||
Log.info("Client connection failed [client=" + client +
|
||||
", cause=" + cause + "].");
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public boolean clientWillLogoff (Client client)
|
||||
{
|
||||
Log.info("Client will logoff [client=" + client + "].");
|
||||
return true;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientDidLogoff (Client client)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Client.java,v 1.20 2002/02/09 20:45:23 mdb Exp $
|
||||
// $Id: Client.java,v 1.21 2002/03/11 19:51:25 mdb Exp $
|
||||
|
||||
package com.threerings.presents.client;
|
||||
|
||||
@@ -68,8 +68,9 @@ public class Client
|
||||
* observer.
|
||||
*
|
||||
* @see ClientObserver
|
||||
* @see SessionObserver
|
||||
*/
|
||||
public void addClientObserver (ClientObserver observer)
|
||||
public void addClientObserver (SessionObserver observer)
|
||||
{
|
||||
synchronized (_observers) {
|
||||
// disallow multiple instances of the same observer
|
||||
@@ -84,7 +85,7 @@ public class Client
|
||||
* the observer will no longer receive notifications of state changes
|
||||
* within the client.
|
||||
*/
|
||||
public void removeClientObserver (ClientObserver observer)
|
||||
public void removeClientObserver (SessionObserver observer)
|
||||
{
|
||||
synchronized (_observers) {
|
||||
_observers.remove(observer);
|
||||
@@ -265,20 +266,27 @@ public class Client
|
||||
boolean rejected = false;
|
||||
synchronized (_observers) {
|
||||
for (int i = 0; i < _observers.size(); i++) {
|
||||
ClientObserver obs = (ClientObserver)_observers.get(i);
|
||||
SessionObserver obs = (SessionObserver)_observers.get(i);
|
||||
switch (code) {
|
||||
case CLIENT_DID_LOGON:
|
||||
obs.clientDidLogon(this);
|
||||
break;
|
||||
case CLIENT_FAILED_TO_LOGON:
|
||||
obs.clientFailedToLogon(this, cause);
|
||||
if (obs instanceof ClientObserver) {
|
||||
((ClientObserver)obs).clientFailedToLogon(this, cause);
|
||||
}
|
||||
break;
|
||||
case CLIENT_CONNECTION_FAILED:
|
||||
obs.clientConnectionFailed(this, cause);
|
||||
if (obs instanceof ClientObserver) {
|
||||
((ClientObserver)obs).clientConnectionFailed(
|
||||
this, cause);
|
||||
}
|
||||
break;
|
||||
case CLIENT_WILL_LOGOFF:
|
||||
if (!obs.clientWillLogoff(this)) {
|
||||
rejected = true;
|
||||
if (obs instanceof ClientObserver) {
|
||||
if (!((ClientObserver)obs).clientWillLogoff(this)) {
|
||||
rejected = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CLIENT_DID_LOGOFF:
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
//
|
||||
// $Id: ClientObserver.java,v 1.3 2001/10/11 04:07:52 mdb Exp $
|
||||
// $Id: ClientObserver.java,v 1.4 2002/03/11 19:51:25 mdb Exp $
|
||||
|
||||
package com.threerings.presents.client;
|
||||
|
||||
/**
|
||||
* A client observer is registered with the client instance to be notified
|
||||
* when state changes happen within the client. Specifically, logon
|
||||
* sucess/failure and logoff.
|
||||
*
|
||||
* <p> These callbacks happen on the client thread and should therefore
|
||||
* not be used to perform any complex action or do much more than relay
|
||||
* the signal to some other thread (like the AWT thread) to act more fully
|
||||
* on the notice.
|
||||
* A client observer is a more detailed version of the {@link
|
||||
* SessionObserver} for entities that are interested in more detail about
|
||||
* the logon/logoff process.
|
||||
*
|
||||
* <p> In the normal course of affairs, <code>clientDidLogon</code> will
|
||||
* be called after the client successfully logs on to the server and
|
||||
@@ -33,16 +28,14 @@ package com.threerings.presents.client;
|
||||
* observers know that we lost our connection to the
|
||||
* server. <code>clientDidLogoff</code> will be called immediately
|
||||
* afterwards as a normal logoff procedure is effected.
|
||||
*
|
||||
* <p> These callbacks happen on the client thread and should therefore
|
||||
* not be used to perform any complex action or do much more than relay
|
||||
* the signal to some other thread (like the AWT thread) to act more fully
|
||||
* on the notice.
|
||||
*/
|
||||
public interface ClientObserver
|
||||
public interface ClientObserver extends SessionObserver
|
||||
{
|
||||
/**
|
||||
* Called after the client successfully connected to and authenticated
|
||||
* with the server. The entire object system is up and running by the
|
||||
* time this method is called.
|
||||
*/
|
||||
public void clientDidLogon (Client client);
|
||||
|
||||
/**
|
||||
* Called if anything fails during the logon attempt. This could be a
|
||||
* network failure, authentication failure or otherwise. The exception
|
||||
@@ -63,10 +56,4 @@ public interface ClientObserver
|
||||
* request.
|
||||
*/
|
||||
public boolean clientWillLogoff (Client client);
|
||||
|
||||
/**
|
||||
* Called after the client has been logged off of the server and has
|
||||
* disconnected.
|
||||
*/
|
||||
public void clientDidLogoff (Client client);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// $Id: SessionObserver.java,v 1.1 2002/03/11 19:51:25 mdb Exp $
|
||||
|
||||
package com.threerings.presents.client;
|
||||
|
||||
/**
|
||||
* A session observer is registered with the client instance to be
|
||||
* notified when the client establishes and ends their session with the
|
||||
* server.
|
||||
*
|
||||
* <p> These callbacks happen on the client thread and should therefore
|
||||
* not be used to perform any complex action or do much more than relay
|
||||
* the signal to some other thread (like the AWT thread) to act more fully
|
||||
* on the notice.
|
||||
*
|
||||
* @see ClientObserver
|
||||
*/
|
||||
public interface SessionObserver
|
||||
{
|
||||
/**
|
||||
* Called after the client successfully connected to and authenticated
|
||||
* with the server. The entire object system is up and running by the
|
||||
* time this method is called.
|
||||
*/
|
||||
public void clientDidLogon (Client client);
|
||||
|
||||
/**
|
||||
* Called after the client has been logged off of the server and has
|
||||
* disconnected.
|
||||
*/
|
||||
public void clientDidLogoff (Client client);
|
||||
}
|
||||
Reference in New Issue
Block a user