Allow bureau clients to report fatal errors if something goes wrong, like oh I don't know... maybe a disconnection perhaps
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5489 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -38,6 +38,14 @@ public class BureauDirector extends BasicDirector
|
|||||||
_bureauService.bureauInitialized(_ctx.getClient(), id);
|
_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.
|
* Creates a new agent when the server requests it.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ public interface BureauService extends InvocationService
|
|||||||
// from Java interface BureauService
|
// from Java interface BureauService
|
||||||
function agentDestroyed (arg1 :Client, arg2 :int) :void;
|
function agentDestroyed (arg1 :Client, arg2 :int) :void;
|
||||||
|
|
||||||
|
// from Java interface BureauService
|
||||||
|
function bureauError (arg1 :Client, arg2 :String) :void;
|
||||||
|
|
||||||
// from Java interface BureauService
|
// from Java interface BureauService
|
||||||
function bureauInitialized (arg1 :Client, arg2 :String) :void;
|
function bureauInitialized (arg1 :Client, arg2 :String) :void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,19 @@ public class BureauMarshaller extends InvocationMarshaller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The method id used to dispatch <code>bureauError</code> 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 <code>bureauInitialized</code> requests. */
|
/** The method id used to dispatch <code>bureauInitialized</code> requests. */
|
||||||
public static const BUREAU_INITIALIZED :int = 4;
|
public static const BUREAU_INITIALIZED :int = 5;
|
||||||
|
|
||||||
// from interface BureauService
|
// from interface BureauService
|
||||||
public function bureauInitialized (arg1 :Client, arg2 :String) :void
|
public function bureauInitialized (arg1 :Client, arg2 :String) :void
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public interface BureauService extends InvocationService
|
|||||||
* @see BureauReceiver
|
* @see BureauReceiver
|
||||||
*/
|
*/
|
||||||
void bureauInitialized (Client client, String bureauId);
|
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.
|
* Notify the server that a previosuly requested agent is now created and ready to use.
|
||||||
|
|||||||
@@ -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. */
|
/** 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
|
// from interface BureauService
|
||||||
public void bureauInitialized (Client arg1, String arg2)
|
public void bureauInitialized (Client arg1, String arg2)
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ public class BureauDispatcher extends InvocationDispatcher<BureauMarshaller>
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case BureauMarshaller.BUREAU_ERROR:
|
||||||
|
((BureauProvider)provider).bureauError(
|
||||||
|
source, (String)args[0]
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
case BureauMarshaller.BUREAU_INITIALIZED:
|
case BureauMarshaller.BUREAU_INITIALIZED:
|
||||||
((BureauProvider)provider).bureauInitialized(
|
((BureauProvider)provider).bureauInitialized(
|
||||||
source, (String)args[0]
|
source, (String)args[0]
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ public interface BureauProvider extends InvocationProvider
|
|||||||
*/
|
*/
|
||||||
void agentDestroyed (ClientObject caller, int arg1);
|
void agentDestroyed (ClientObject caller, int arg1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a {@link BureauService#bureauError} request.
|
||||||
|
*/
|
||||||
|
void bureauError (ClientObject caller, String arg1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a {@link BureauService#bureauInitialized} request.
|
* Handles a {@link BureauService#bureauInitialized} request.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ public class BureauRegistry
|
|||||||
public void bureauInitialized (ClientObject client, String bureauId) {
|
public void bureauInitialized (ClientObject client, String bureauId) {
|
||||||
BureauRegistry.this.bureauInitialized(client, 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) {
|
public void agentCreated (ClientObject client, int agentId) {
|
||||||
BureauRegistry.this.agentCreated(client, agentId);
|
BureauRegistry.this.agentCreated(client, agentId);
|
||||||
}
|
}
|
||||||
@@ -396,6 +399,22 @@ public class BureauRegistry
|
|||||||
bureau.summarize();
|
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.
|
* Callback for when the bureau client acknowledges the creation of an agent.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user