Allow a custom error handler to be provided to the TableDirector.

If ActionScript supported anonymous classes, TableDirector would not have to
implement InvocationService_ResultListener and could instead define a calldown
handleFailure() method that the client could override by anonymously extending
TableDirector at the point of instantiation and customize the failure handling
thusly. But it doesn't, and so we pollute TableDirector with yet more methods
that many clients probably don't care about.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@763 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-10-23 20:08:47 +00:00
parent 68c4218324
commit 8a76c0de9f
@@ -164,6 +164,18 @@ public class TableDirector extends BasicDirector
return _ourTable;
}
/**
* By default, failure is handled by reporting feedback via the chat director. Clients that
* require custom error handling can provide a function with the signature:
* <pre>
* function (cause :String) :void
* </pre>
*/
public function setFailureHandler (handler :Function) :void
{
_failureHandler = handler;
}
/**
* Sends a request to create a table with the specified game configuration. This user will
* become the owner of this table and will be added to the first position in the table. The
@@ -344,7 +356,11 @@ public class TableDirector extends BasicDirector
// documentation inherited from interface
public function requestFailed (reason :String) :void
{
_pctx.getChatDirector().displayFeedback(_errorBundle, reason);
if (_failureHandler != null) {
_failureHandler(reason);
} else {
_pctx.getChatDirector().displayFeedback(_errorBundle, reason);
}
}
/**
@@ -405,5 +421,8 @@ public class TableDirector extends BasicDirector
/** An array of entities that want to hear about when we stand up or sit down. */
protected var _seatedObservers :ObserverList = new ObserverList();
/** A custom failure handler, or null. */
protected var _failureHandler :Function;
}
}