Pass a message along with a FailureResponse.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4819 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-08-22 01:15:39 +00:00
parent 9a150ebcda
commit 810969f6f9
6 changed files with 26 additions and 17 deletions
@@ -198,8 +198,7 @@ public class ClientDObjectMgr
} }
} else if (obj is FailureResponse) { } else if (obj is FailureResponse) {
var foid :int = (obj as FailureResponse).getOid(); notifyFailure((obj as FailureResponse).getOid(), (obj as FailureResponse).getMessage());
notifyFailure(foid);
} else if (obj is PongResponse) { } else if (obj is PongResponse) {
_client.gotPong(obj as PongResponse); _client.gotPong(obj as PongResponse);
@@ -303,7 +302,7 @@ public class ClientDObjectMgr
* Notifies the subscribers that had requested this object (for subscription) that it is not * Notifies the subscribers that had requested this object (for subscription) that it is not
* available. * available.
*/ */
protected function notifyFailure (oid :int) :void protected function notifyFailure (oid :int, message :String) :void
{ {
// let the penders know that the object is not available // let the penders know that the object is not available
var req :PendingRequest = (_penders.remove(oid) as PendingRequest); var req :PendingRequest = (_penders.remove(oid) as PendingRequest);
@@ -315,7 +314,7 @@ public class ClientDObjectMgr
for (var ii :int = 0; ii < req.targets.length; ii++) { for (var ii :int = 0; ii < req.targets.length; ii++) {
var target :Subscriber = req.targets[ii]; var target :Subscriber = req.targets[ii];
// and let them know that the object is in // and let them know that the object is in
target.requestFailed(oid, new ObjectAccessError("No such object " + oid + ".")); target.requestFailed(oid, new ObjectAccessError(message));
} }
} }
@@ -30,17 +30,24 @@ public class FailureResponse extends DownstreamMessage
return _oid; return _oid;
} }
public function getMessage () :String
{
return _message;
}
public function toString () :String public function toString () :String
{ {
return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + "]"; return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + ", msg=" + _message + "]";
} }
override public function readObject (ins :ObjectInputStream) :void override public function readObject (ins :ObjectInputStream) :void
{ {
super.readObject(ins); super.readObject(ins);
_oid = ins.readInt(); _oid = ins.readInt();
_message = ins.readUTF();
} }
protected var _oid :int; protected var _oid :int;
protected var _message :String;
} }
} }
@@ -169,8 +169,7 @@ public class ClientDObjectMgr
} }
} else if (obj instanceof FailureResponse) { } else if (obj instanceof FailureResponse) {
int oid = ((FailureResponse)obj).getOid(); notifyFailure(((FailureResponse)obj).getOid(), ((FailureResponse)obj).getMessage());
notifyFailure(oid);
} else if (obj instanceof PongResponse) { } else if (obj instanceof PongResponse) {
_client.gotPong((PongResponse)obj); _client.gotPong((PongResponse)obj);
@@ -303,7 +302,7 @@ public class ClientDObjectMgr
* Notifies the subscribers that had requested this object (for subscription) that it is not * Notifies the subscribers that had requested this object (for subscription) that it is not
* available. * available.
*/ */
protected void notifyFailure (int oid) protected void notifyFailure (int oid, String message)
{ {
// let the penders know that the object is not available // let the penders know that the object is not available
PendingRequest<?> req = _penders.remove(oid); PendingRequest<?> req = _penders.remove(oid);
@@ -313,8 +312,7 @@ public class ClientDObjectMgr
} }
for (int i = 0; i < req.targets.size(); i++) { for (int i = 0; i < req.targets.size(); i++) {
// and let them know that the object is in req.targets.get(i).requestFailed(oid, new ObjectAccessException(message));
req.targets.get(i).requestFailed(oid, null);
} }
} }
@@ -30,8 +30,7 @@ package com.threerings.presents.dobj;
public class ObjectAccessException extends Exception public class ObjectAccessException extends Exception
{ {
/** /**
* Constructs a object access exception with the specified error * Constructs a object access exception with the specified error message.
* message.
*/ */
public ObjectAccessException (String message) public ObjectAccessException (String message)
{ {
@@ -32,12 +32,12 @@ public class FailureResponse extends DownstreamMessage
} }
/** /**
* Constructs a failure response in response to a request for the * Constructs a failure response in response to a request for the specified oid.
* specified oid.
*/ */
public FailureResponse (int oid) public FailureResponse (int oid, String message)
{ {
_oid = oid; _oid = oid;
_message = message;
} }
public int getOid () public int getOid ()
@@ -45,10 +45,16 @@ public class FailureResponse extends DownstreamMessage
return _oid; return _oid;
} }
public String getMessage ()
{
return _message;
}
public String toString () public String toString ()
{ {
return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + "]"; return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + ", msg=" + _message + "]";
} }
protected int _oid; protected int _oid;
protected String _message;
} }
@@ -820,7 +820,7 @@ public class PresentsClient
// from interface ProxySubscriber // from interface ProxySubscriber
public void requestFailed (int oid, ObjectAccessException cause) public void requestFailed (int oid, ObjectAccessException cause)
{ {
postMessage(new FailureResponse(oid)); postMessage(new FailureResponse(oid, cause.getMessage()));
} }
// from interface ProxySubscriber // from interface ProxySubscriber