Fixed bug with long running clients. The results for invocation requests with ids exceeding Short.MAX_VALUE could not be processed due to the id being deserialized as a short but stored in the map with an integer key.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5483 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Jamie Doornbos
2008-10-30 17:15:42 +00:00
parent f511469901
commit ed0718674e
@@ -27,6 +27,7 @@ import flash.utils.getTimer; // function import
import com.threerings.util.Boxed;
import com.threerings.util.HashMap;
import com.threerings.util.Log;
import com.threerings.util.Short;
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
@@ -340,11 +341,22 @@ public class InvocationDirector
}
/**
* Used to generate monotonically increasing invocation request ids.
* Used to generate (almost) monotonically increasing invocation request ids. The ids wrap
* around to Short.MIN_VALUE after Short.MAX_VALUE is reached.
*/
protected function nextRequestId () :int
{
return _requestId++;
// post increment with wraparound - this is necessary because the request id is
// serialized as a java short in all instances. since action script does not appear
// to support sign extension, wraparound in the integer domain explicitly. This will
// make the values in our _listeners map reliable. Cleverer ways to wrapround may exist.
var current :int = _requestId;
if (_requestId == Short.MAX_VALUE) { // x7fff
_requestId = -Short.MIN_VALUE; // x8000
} else {
_requestId++;
}
return current;
}
/**