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;
|
package com.threerings.crowd.client;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ import com.threerings.crowd.util.CrowdContext;
|
|||||||
* before actually issuing the request.
|
* before actually issuing the request.
|
||||||
*/
|
*/
|
||||||
public class LocationDirector
|
public class LocationDirector
|
||||||
implements ClientObserver, Subscriber
|
implements SessionObserver, Subscriber
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Used to recover from a moveTo request that was accepted but
|
* 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
|
// 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)
|
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;
|
package com.threerings.micasa.client;
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import com.samskivert.swing.Controller;
|
|||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.presents.client.Client;
|
import com.threerings.presents.client.Client;
|
||||||
import com.threerings.presents.client.ClientObserver;
|
import com.threerings.presents.client.SessionObserver;
|
||||||
|
|
||||||
import com.threerings.crowd.data.BodyObject;
|
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.
|
* Responsible for top-level control of the client user interface.
|
||||||
*/
|
*/
|
||||||
public class ClientController
|
public class ClientController extends Controller
|
||||||
extends Controller
|
implements SessionObserver
|
||||||
implements ClientObserver
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a new client controller. The controller will set everything
|
* 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
|
// documentation inherited
|
||||||
public void clientDidLogoff (Client client)
|
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;
|
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.
|
* Responsible for top-level control of the client user interface.
|
||||||
*/
|
*/
|
||||||
public class ClientController
|
public class ClientController extends Controller
|
||||||
extends Controller
|
implements SessionObserver
|
||||||
implements ClientObserver
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a new client controller. The controller will set everything
|
* 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
|
// documentation inherited
|
||||||
public void clientDidLogoff (Client client)
|
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;
|
package com.threerings.presents.client;
|
||||||
|
|
||||||
@@ -68,8 +68,9 @@ public class Client
|
|||||||
* observer.
|
* observer.
|
||||||
*
|
*
|
||||||
* @see ClientObserver
|
* @see ClientObserver
|
||||||
|
* @see SessionObserver
|
||||||
*/
|
*/
|
||||||
public void addClientObserver (ClientObserver observer)
|
public void addClientObserver (SessionObserver observer)
|
||||||
{
|
{
|
||||||
synchronized (_observers) {
|
synchronized (_observers) {
|
||||||
// disallow multiple instances of the same observer
|
// disallow multiple instances of the same observer
|
||||||
@@ -84,7 +85,7 @@ public class Client
|
|||||||
* the observer will no longer receive notifications of state changes
|
* the observer will no longer receive notifications of state changes
|
||||||
* within the client.
|
* within the client.
|
||||||
*/
|
*/
|
||||||
public void removeClientObserver (ClientObserver observer)
|
public void removeClientObserver (SessionObserver observer)
|
||||||
{
|
{
|
||||||
synchronized (_observers) {
|
synchronized (_observers) {
|
||||||
_observers.remove(observer);
|
_observers.remove(observer);
|
||||||
@@ -265,20 +266,27 @@ public class Client
|
|||||||
boolean rejected = false;
|
boolean rejected = false;
|
||||||
synchronized (_observers) {
|
synchronized (_observers) {
|
||||||
for (int i = 0; i < _observers.size(); i++) {
|
for (int i = 0; i < _observers.size(); i++) {
|
||||||
ClientObserver obs = (ClientObserver)_observers.get(i);
|
SessionObserver obs = (SessionObserver)_observers.get(i);
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case CLIENT_DID_LOGON:
|
case CLIENT_DID_LOGON:
|
||||||
obs.clientDidLogon(this);
|
obs.clientDidLogon(this);
|
||||||
break;
|
break;
|
||||||
case CLIENT_FAILED_TO_LOGON:
|
case CLIENT_FAILED_TO_LOGON:
|
||||||
obs.clientFailedToLogon(this, cause);
|
if (obs instanceof ClientObserver) {
|
||||||
|
((ClientObserver)obs).clientFailedToLogon(this, cause);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CLIENT_CONNECTION_FAILED:
|
case CLIENT_CONNECTION_FAILED:
|
||||||
obs.clientConnectionFailed(this, cause);
|
if (obs instanceof ClientObserver) {
|
||||||
|
((ClientObserver)obs).clientConnectionFailed(
|
||||||
|
this, cause);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CLIENT_WILL_LOGOFF:
|
case CLIENT_WILL_LOGOFF:
|
||||||
if (!obs.clientWillLogoff(this)) {
|
if (obs instanceof ClientObserver) {
|
||||||
rejected = true;
|
if (!((ClientObserver)obs).clientWillLogoff(this)) {
|
||||||
|
rejected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CLIENT_DID_LOGOFF:
|
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;
|
package com.threerings.presents.client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A client observer is registered with the client instance to be notified
|
* A client observer is a more detailed version of the {@link
|
||||||
* when state changes happen within the client. Specifically, logon
|
* SessionObserver} for entities that are interested in more detail about
|
||||||
* sucess/failure and logoff.
|
* the logon/logoff process.
|
||||||
*
|
|
||||||
* <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.
|
|
||||||
*
|
*
|
||||||
* <p> In the normal course of affairs, <code>clientDidLogon</code> will
|
* <p> In the normal course of affairs, <code>clientDidLogon</code> will
|
||||||
* be called after the client successfully logs on to the server and
|
* 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
|
* observers know that we lost our connection to the
|
||||||
* server. <code>clientDidLogoff</code> will be called immediately
|
* server. <code>clientDidLogoff</code> will be called immediately
|
||||||
* afterwards as a normal logoff procedure is effected.
|
* 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
|
* Called if anything fails during the logon attempt. This could be a
|
||||||
* network failure, authentication failure or otherwise. The exception
|
* network failure, authentication failure or otherwise. The exception
|
||||||
@@ -63,10 +56,4 @@ public interface ClientObserver
|
|||||||
* request.
|
* request.
|
||||||
*/
|
*/
|
||||||
public boolean clientWillLogoff (Client client);
|
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