Open
Description
protobuf.js version: 6.7.1
I'm trying to implement streaming RPC function, to create services. But looking at the streaming example, I don't understand how I can emit these events:
greeter.on("data", function(response, method) { // data function
console.log("data in " + method.name + ":", response.message);
});
greeter.on("end", function() { // end function
console.log("end");
});
greeter.on("error", function(err, method) { // error function
console.log("error in " + method.name + ":", err);
});
greeter.on("status", function(code, text) { // status function
console.log("custom status:", code, text);
});
from the rpcImpl
function:
// I only have a callback function. It's OK for unary method, but how to use for streaming method (data, end, error, status events)
var greeter = Greeter.create(function myRPCImpl(method, requestData, callback) {
responseData = fetch();
callback(null, responseData);
};
});
My guess is:
- data event: multiple call to
callback(null, data)
. - end event: calling
callback(null, null)
. - error event: calling
callback(error)
. - status event: ???
If that's correct, does it also mean that rpcImpl
will automatically fire events when receiving a streaming method, and fire a promise when receiving a unary method? Or fire both whatever the method?
Thank you for the clarification!