|
|
@ -95,7 +95,6 @@ function setUpWritable(stream, serialize) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
stream.serialize = common.wrapIgnoreNull(serialize); |
|
|
|
stream.serialize = common.wrapIgnoreNull(serialize); |
|
|
|
function sendStatus() { |
|
|
|
function sendStatus() { |
|
|
|
console.log('Server sending status'); |
|
|
|
|
|
|
|
var batch = {}; |
|
|
|
var batch = {}; |
|
|
|
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = stream.status; |
|
|
|
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = stream.status; |
|
|
|
stream.call.startBatch(batch, function(){}); |
|
|
|
stream.call.startBatch(batch, function(){}); |
|
|
@ -169,7 +168,6 @@ function ServerWritableStream(call, serialize) { |
|
|
|
function _write(chunk, encoding, callback) { |
|
|
|
function _write(chunk, encoding, callback) { |
|
|
|
var batch = {}; |
|
|
|
var batch = {}; |
|
|
|
batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); |
|
|
|
batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); |
|
|
|
console.log('Server writing', batch); |
|
|
|
|
|
|
|
this.call.startBatch(batch, function(err, value) { |
|
|
|
this.call.startBatch(batch, function(err, value) { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
this.emit('error', err); |
|
|
|
this.emit('error', err); |
|
|
@ -207,14 +205,11 @@ function _read(size) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (self.finished) { |
|
|
|
if (self.finished) { |
|
|
|
console.log('Pushing null'); |
|
|
|
|
|
|
|
self.push(null); |
|
|
|
self.push(null); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var data = event.read; |
|
|
|
var data = event.read; |
|
|
|
console.log(data); |
|
|
|
|
|
|
|
if (self.push(self.deserialize(data)) && data != null) { |
|
|
|
if (self.push(self.deserialize(data)) && data != null) { |
|
|
|
console.log('Reading again'); |
|
|
|
|
|
|
|
var read_batch = {}; |
|
|
|
var read_batch = {}; |
|
|
|
read_batch[grpc.opType.RECV_MESSAGE] = true; |
|
|
|
read_batch[grpc.opType.RECV_MESSAGE] = true; |
|
|
|
self.call.startBatch(read_batch, readCallback); |
|
|
|
self.call.startBatch(read_batch, readCallback); |
|
|
@ -276,7 +271,6 @@ function handleUnary(call, handler, metadata) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleServerStreaming(call, handler, metadata) { |
|
|
|
function handleServerStreaming(call, handler, metadata) { |
|
|
|
console.log('Handling server streaming call'); |
|
|
|
|
|
|
|
var stream = new ServerWritableStream(call, handler.serialize); |
|
|
|
var stream = new ServerWritableStream(call, handler.serialize); |
|
|
|
waitForCancel(call, stream); |
|
|
|
waitForCancel(call, stream); |
|
|
|
var batch = {}; |
|
|
|
var batch = {}; |
|
|
@ -360,7 +354,6 @@ function Server(getMetadata, options) { |
|
|
|
* @param {grpc.Event} event The event to handle with tag SERVER_RPC_NEW |
|
|
|
* @param {grpc.Event} event The event to handle with tag SERVER_RPC_NEW |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function handleNewCall(err, event) { |
|
|
|
function handleNewCall(err, event) { |
|
|
|
console.log('Handling new call'); |
|
|
|
|
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -376,9 +369,7 @@ function Server(getMetadata, options) { |
|
|
|
var deadline = details.deadline; |
|
|
|
var deadline = details.deadline; |
|
|
|
if (handlers.hasOwnProperty(method)) { |
|
|
|
if (handlers.hasOwnProperty(method)) { |
|
|
|
handler = handlers[method]; |
|
|
|
handler = handlers[method]; |
|
|
|
console.log(handler); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.log(handlers); |
|
|
|
|
|
|
|
var batch = {}; |
|
|
|
var batch = {}; |
|
|
|
batch[grpc.opType.SEND_INITIAL_METADATA] = {}; |
|
|
|
batch[grpc.opType.SEND_INITIAL_METADATA] = {}; |
|
|
|
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = { |
|
|
|
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = { |
|
|
|