A little bit of tweakery so that the invocation director to use

is known by any invocation marshaller, and so the client does
not need to be passed in.

Just here on the actionscript side for now, but this change may
make its way to Java.

Other changes may follow...


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5904 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2009-08-13 06:17:28 +00:00
parent 505a9c3a53
commit fe3d89132d
4 changed files with 27 additions and 11 deletions
+15 -2
View File
@@ -38,12 +38,13 @@ public class ObjectInputStream
public static const log :Log = Log.getLog(ObjectInputStream);
public function ObjectInputStream (source :IDataInput = null)
public function ObjectInputStream (source :IDataInput = null, clientProps :Object = null)
{
if (source == null) {
source = new ByteArray();
}
_source = source;
_source = source || new ByteArray();
_cliProps = clientProps || {};
}
/**
@@ -54,6 +55,15 @@ public class ObjectInputStream
_source = source;
}
/**
* Return a "client property" with the specified name.
* Actionscript only.
*/
public function getClientProperty (name :String) :*
{
return _cliProps[name];
}
/**
* Attempts to read the next object from the stream. If a type is passed and the read object's
* type doesn't match, a <code>TypeError</code> is thrown.
@@ -247,6 +257,9 @@ public class ObjectInputStream
return _source.readUTF();
}
/** Named "client properties" that we can provide to deserialized objects. */
protected var _cliProps :Object;
/** The target DataInput that we route input from. */
protected var _source :IDataInput;
@@ -61,7 +61,7 @@ public class Communicator
_outBuffer = new ByteArray();
_outBuffer.endian = Endian.BIG_ENDIAN;
_outStream = new ObjectOutputStream(_outBuffer);
_inStream = new ObjectInputStream();
_inStream = new ObjectInputStream(null, { invDir: _client.getInvocationDirector() });
attemptLogon(0);
}
@@ -28,6 +28,7 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationDirector;
import com.threerings.presents.client.InvocationService;
import com.threerings.presents.dobj.DObjectManager;
@@ -73,11 +74,9 @@ public class InvocationMarshaller
* Called by generated invocation marshaller code; packages up and
* sends the specified invocation service request.
*/
protected function sendRequest (
client :Client, methodId :int, args :Array) :void
protected function sendRequest (methodId :int, args :Array) :void
{
client.getInvocationDirector().sendRequest(
_invOid, _invCode, methodId, args);
_invDir.sendRequest(_invOid, _invCode, methodId, args);
}
/**
@@ -101,6 +100,9 @@ public class InvocationMarshaller
{
_invOid = ins.readInt();
_invCode = ins.readInt();
// this is sorta hacky, but so is actionscript.
_invDir = ins.getClientProperty("invDir");
}
/** The oid of the invocation object, where invocation service
@@ -110,5 +112,8 @@ public class InvocationMarshaller
/** The invocation service code assigned to this service when it was
* registered on the server. */
protected var _invCode :int;
/** The invocation director we use. */
protected var _invDir :InvocationDirector;
}
}
@@ -60,10 +60,8 @@ public class InvocationMarshaller_ListenerMarshaller
listener.requestFailed((args[0] as String));
} else {
Log.getLog(this).warning(
"Requested to dispatch unknown invocation response " +
"[listener=" + listener + ", methodId=" + methodId +
", args=" + args + "].");
Log.getLog(this).warning("Requested to dispatch unknown invocation response",
"listener", listener, "methodId", methodId, "args", args);
}
}