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: 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