Allow client resolution to bail out in an orderly fashion is a disconnection occurs
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5640 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -45,6 +45,13 @@ import static com.threerings.presents.Log.log;
|
|||||||
*/
|
*/
|
||||||
public class ClientResolver extends Invoker.Unit
|
public class ClientResolver extends Invoker.Unit
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Thrown during resolution if the client disconnects.
|
||||||
|
*/
|
||||||
|
public static class ClientDisconnectedException extends Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiailizes this instance.
|
* Initiailizes this instance.
|
||||||
*
|
*
|
||||||
@@ -191,6 +198,17 @@ public class ClientResolver extends Invoker.Unit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if the client being resolved is no longer connected.
|
||||||
|
*/
|
||||||
|
protected void enforceConnected ()
|
||||||
|
throws ClientDisconnectedException
|
||||||
|
{
|
||||||
|
if (_clmgr.getClient(_username) == null) {
|
||||||
|
throw new ClientDisconnectedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The name of the user whose client object is being resolved. */
|
/** The name of the user whose client object is being resolved. */
|
||||||
protected Name _username;
|
protected Name _username;
|
||||||
|
|
||||||
@@ -206,4 +224,5 @@ public class ClientResolver extends Invoker.Unit
|
|||||||
// dependencies
|
// dependencies
|
||||||
protected @Inject @MainInvoker Invoker _invoker;
|
protected @Inject @MainInvoker Invoker _invoker;
|
||||||
protected @Inject RootDObjectManager _omgr;
|
protected @Inject RootDObjectManager _omgr;
|
||||||
|
protected @Inject ClientManager _clmgr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,8 +388,13 @@ public class PresentsSession
|
|||||||
// from interface ClientResolutionListener
|
// from interface ClientResolutionListener
|
||||||
public void resolutionFailed (Name username, Exception reason)
|
public void resolutionFailed (Name username, Exception reason)
|
||||||
{
|
{
|
||||||
// urk; nothing to do but complain and get the f**k out of dodge
|
if (reason instanceof ClientResolver.ClientDisconnectedException) {
|
||||||
log.warning("Unable to resolve client", "username", username, reason);
|
log.info("Client disconnected during resolution", "username", username);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// urk; nothing to do but complain and get the f**k out of dodge
|
||||||
|
log.warning("Unable to resolve client", "username", username, reason);
|
||||||
|
}
|
||||||
|
|
||||||
// end the session now to prevent danglage
|
// end the session now to prevent danglage
|
||||||
endSession();
|
endSession();
|
||||||
|
|||||||
Reference in New Issue
Block a user