Merge branch 'decode2' into decode3
Change-Id: I1551d440da0f2c9198d8aec72c089f8c05188a67
diff --git a/src/naming/namespace.js b/src/naming/namespace.js
index 89d32c8..7467c83 100644
--- a/src/naming/namespace.js
+++ b/src/naming/namespace.js
@@ -95,7 +95,7 @@
* @param {string} server Server object address
* @param {number} ttl Expiry time for the mount in milliseconds. ttl of zero
* implies never expire.
- * @param {boolean} Optional replaceMount Whether the previous mount should
+ * @param {boolean} [replaceMount] Whether the previous mount should
* be replaced by the new server object address. False by default.
* @param {function} cb(error) Optional callback
* @return {Promise} A promise to be resolved when mount is complete or rejected
diff --git a/src/proxy/stream-handler.js b/src/proxy/stream-handler.js
index b0df421..672890c 100644
--- a/src/proxy/stream-handler.js
+++ b/src/proxy/stream-handler.js
@@ -22,12 +22,13 @@
* @param {Stream} Stream instance
* @constructor
*/
-function Handler(ctx, stream) {
+function Handler(ctx, stream, typeDecoder) {
this._ctx = ctx;
this._stream = stream;
this._controller = ctx.value(SharedContextKeys.RUNTIME)._controller;
this._pendingBlessings = [];
this._tasks = new TaskSequence();
+ this._typeDecoder = typeDecoder;
}
Handler.prototype.handleResponse = function(type, data) {
@@ -57,7 +58,7 @@
return Promise.resolve();
}
var handler = this;
- return vom.decode(data).then(function(data) {
+ return vom.decode(data, false, this._typeDecoder).then(function(data) {
if (data instanceof BlessingsId) {
var runtime = runtimeFromContext(handler._ctx);
runtime.blessingsManager.blessingsFromId(data)
diff --git a/src/proxy/stream.js b/src/proxy/stream.js
index e218fab..7949074 100644
--- a/src/proxy/stream.js
+++ b/src/proxy/stream.js
@@ -43,7 +43,8 @@
* @inner
* @memberof module:vanadium.rpc
*/
-var Stream = function(flowId, webSocketPromise, isClient, readType, writeType) {
+var Stream = function(flowId, webSocketPromise, isClient, readType, writeType,
+ typeEncoder) {
Duplex.call(this, { objectMode: true });
this.flowId = flowId;
this.isClient = isClient;
@@ -51,6 +52,7 @@
this.writeType = writeType;
this.webSocketPromise = webSocketPromise;
this.onmessage = null;
+ this._typeEncoder = typeEncoder;
// The buffer of messages that will be passed to push
// when the internal buffer has room.
@@ -82,7 +84,7 @@
results: results,
err: err || null,
traceResponse: traceResponse
- }))
+ }, null, this._typeEncoder))
};
Duplex.prototype.write.call(this, object);
};
diff --git a/src/rpc/client.js b/src/rpc/client.js
index 34511df..840b3ae 100644
--- a/src/rpc/client.js
+++ b/src/rpc/client.js
@@ -170,7 +170,7 @@
// Clients read data of type outStreamingType and write data of type
// inStreamingType.
def.stream = new Stream(this._id, streamingDeferred.promise, true,
- this._outStreamingType, this._inStreamingType);
+ this._outStreamingType, this._inStreamingType, this._typeEncoder);
def.promise.stream = def.stream;
}
@@ -263,7 +263,7 @@
return;
}
var rpc = this;
- return vom.decode(data).then(function(data) {
+ return vom.decode(data, false, this._typeDecoder).then(function(data) {
rpc._def.stream._queueRead(data);
}).catch(function(e) {
rpc.handleError(