-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get client stream method return #1129
Comments
You can see examples of how to use the streaming methods in the tests: https://github.com/improbable-eng/grpc-web/blob/master/integration_test/ts/src/client.websocket.spec.ts. I think you want to use |
Ok, thank you for this message, I understand the problem, and it seems to be in improbable-eng/ts-protoc-gen, not grpc-web. For the method
The js generated is : APIClient.prototype.testClientStream = function testClientStream(metadata) {
var listeners = {
end: [],
status: []
};
var client = grpc.client(API.TestClientStream, {
host: this.serviceHost,
metadata: metadata,
transport: this.options.transport
});
client.onEnd(function (status, statusMessage, trailers) {
listeners.status.forEach(function (handler) {
handler({ code: status, details: statusMessage, metadata: trailers });
});
listeners.end.forEach(function (handler) {
handler({ code: status, details: statusMessage, metadata: trailers });
});
listeners = null;
});
return {
on: function (type, handler) {
listeners[type].push(handler);
return this;
},
write: function (requestMessage) {
if (!client.started) {
client.start(metadata);
}
client.send(requestMessage);
return this;
},
end: function () {
client.finishSend();
},
cancel: function () {
listeners = null;
client.close();
}
};
}; And the TS definition : interface RequestStream<T> {
write(message: T): RequestStream<T>;
end(): void;
cancel(): void;
on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
} As you can see, |
Now fixed in improbable-eng/ts-protoc-gen#264 |
When using a client stream method like :
How can I use the client to receive the returned value ?
RequestStream
only offer the two following methods :none of them contains the returned value.
The returned value is returned like that (in Golang) :
The text was updated successfully, but these errors were encountered: