diff --git a/src/as/com/threerings/bureau/client/BureauDirector.as b/src/as/com/threerings/bureau/client/BureauDirector.as index 4652942a5..8649c8d2c 100644 --- a/src/as/com/threerings/bureau/client/BureauDirector.as +++ b/src/as/com/threerings/bureau/client/BureauDirector.as @@ -38,6 +38,14 @@ public class BureauDirector extends BasicDirector _bureauService.bureauInitialized(_ctx.getClient(), id); } + /** + * Lets the server know that a fatal error has occurred and the bureau needs to be terminated. + */ + public function fatalError (message :String) :void + { + _bureauService.bureauError(_ctx.getClient(), message); + } + /** * Creates a new agent when the server requests it. */ diff --git a/src/as/com/threerings/bureau/client/BureauService.as b/src/as/com/threerings/bureau/client/BureauService.as index 33160df6c..858fa7ae6 100644 --- a/src/as/com/threerings/bureau/client/BureauService.as +++ b/src/as/com/threerings/bureau/client/BureauService.as @@ -38,6 +38,9 @@ public interface BureauService extends InvocationService // from Java interface BureauService function agentDestroyed (arg1 :Client, arg2 :int) :void; + // from Java interface BureauService + function bureauError (arg1 :Client, arg2 :String) :void; + // from Java interface BureauService function bureauInitialized (arg1 :Client, arg2 :String) :void; } diff --git a/src/as/com/threerings/bureau/data/BureauMarshaller.as b/src/as/com/threerings/bureau/data/BureauMarshaller.as index 0077a191b..2e9bb990c 100644 --- a/src/as/com/threerings/bureau/data/BureauMarshaller.as +++ b/src/as/com/threerings/bureau/data/BureauMarshaller.as @@ -69,8 +69,19 @@ public class BureauMarshaller extends InvocationMarshaller ]); } + /** The method id used to dispatch bureauError requests. */ + public static const BUREAU_ERROR :int = 4; + + // from interface BureauService + public function bureauError (arg1 :Client, arg2 :String) :void + { + sendRequest(arg1, BUREAU_ERROR, [ + arg2 + ]); + } + /** The method id used to dispatch bureauInitialized requests. */ - public static const BUREAU_INITIALIZED :int = 4; + public static const BUREAU_INITIALIZED :int = 5; // from interface BureauService public function bureauInitialized (arg1 :Client, arg2 :String) :void diff --git a/src/java/com/threerings/bureau/client/BureauService.java b/src/java/com/threerings/bureau/client/BureauService.java index c9363cb0b..57adfbb2b 100644 --- a/src/java/com/threerings/bureau/client/BureauService.java +++ b/src/java/com/threerings/bureau/client/BureauService.java @@ -35,6 +35,12 @@ public interface BureauService extends InvocationService * @see BureauReceiver */ void bureauInitialized (Client client, String bureauId); + + /** + * Notifies the server that this bureau has encountered a critical error and needs to be shut + * down. + */ + void bureauError (Client client, String message); /** * Notify the server that a previosuly requested agent is now created and ready to use. diff --git a/src/java/com/threerings/bureau/data/BureauMarshaller.java b/src/java/com/threerings/bureau/data/BureauMarshaller.java index 1b8c4e8a8..faa102b87 100644 --- a/src/java/com/threerings/bureau/data/BureauMarshaller.java +++ b/src/java/com/threerings/bureau/data/BureauMarshaller.java @@ -68,8 +68,19 @@ public class BureauMarshaller extends InvocationMarshaller }); } + /** The method id used to dispatch {@link #bureauError} requests. */ + public static final int BUREAU_ERROR = 4; + + // from interface BureauService + public void bureauError (Client arg1, String arg2) + { + sendRequest(arg1, BUREAU_ERROR, new Object[] { + arg2 + }); + } + /** The method id used to dispatch {@link #bureauInitialized} requests. */ - public static final int BUREAU_INITIALIZED = 4; + public static final int BUREAU_INITIALIZED = 5; // from interface BureauService public void bureauInitialized (Client arg1, String arg2) diff --git a/src/java/com/threerings/bureau/server/BureauDispatcher.java b/src/java/com/threerings/bureau/server/BureauDispatcher.java index 2157b592d..2f66763ed 100644 --- a/src/java/com/threerings/bureau/server/BureauDispatcher.java +++ b/src/java/com/threerings/bureau/server/BureauDispatcher.java @@ -70,6 +70,12 @@ public class BureauDispatcher extends InvocationDispatcher ); return; + case BureauMarshaller.BUREAU_ERROR: + ((BureauProvider)provider).bureauError( + source, (String)args[0] + ); + return; + case BureauMarshaller.BUREAU_INITIALIZED: ((BureauProvider)provider).bureauInitialized( source, (String)args[0] diff --git a/src/java/com/threerings/bureau/server/BureauProvider.java b/src/java/com/threerings/bureau/server/BureauProvider.java index 7c82c3853..0cc5a5199 100644 --- a/src/java/com/threerings/bureau/server/BureauProvider.java +++ b/src/java/com/threerings/bureau/server/BureauProvider.java @@ -45,6 +45,11 @@ public interface BureauProvider extends InvocationProvider */ void agentDestroyed (ClientObject caller, int arg1); + /** + * Handles a {@link BureauService#bureauError} request. + */ + void bureauError (ClientObject caller, String arg1); + /** * Handles a {@link BureauService#bureauInitialized} request. */ diff --git a/src/java/com/threerings/bureau/server/BureauRegistry.java b/src/java/com/threerings/bureau/server/BureauRegistry.java index 8d26fd4ff..47df599ba 100644 --- a/src/java/com/threerings/bureau/server/BureauRegistry.java +++ b/src/java/com/threerings/bureau/server/BureauRegistry.java @@ -101,6 +101,9 @@ public class BureauRegistry public void bureauInitialized (ClientObject client, String bureauId) { BureauRegistry.this.bureauInitialized(client, bureauId); } + public void bureauError (ClientObject caller, String message) { + BureauRegistry.this.bureauError(caller, message); + } public void agentCreated (ClientObject client, int agentId) { BureauRegistry.this.agentCreated(client, agentId); } @@ -396,6 +399,22 @@ public class BureauRegistry bureau.summarize(); } + protected void bureauError (ClientObject caller, String message) + { + for (Bureau bureau : _bureaus.values()) { + if (bureau.clientObj == caller) { + log.info( + "Bureau error occurred", "caller", caller.who(), "message", message, + "bureau", bureau.bureauId); + bureau.client.endSession(); + return; + } + } + log.warning( + "Bureau error occurred in unregistered bureau", "caller", caller.who(), + "message", message); + } + /** * Callback for when the bureau client acknowledges the creation of an agent. */