问题描述
以上段落讨论了客户端和服务器,前者是调用方法的服务器.我想知道的是:连接的服务器端是否可以调用已在客户端上注册的方法?
The above paragraph talks about a client and a server, with the former being the one who is invoking methods to the other. What am I wondering is: can the server-end of the connection invoke methods that have been registered on the client?
推荐答案
否,服务器无法在客户端上调用呼叫. gRPC使用 HTTP,并且HTTP过去没有这种语义.
No, a server cannot invoke calls on the client. gRPC works with HTTP, and HTTP has not had such semantics in the past.
关于实现此功能的各种方法已经进行了讨论,但是我不知道在设计上已经开始的任何工作或未达成普遍协议. gRPC确实支持双向流传输,这可能会为您带来一些所需的东西.通过双向流传输,客户端可以响应来自服务器的消息,但是客户端仍在呼叫服务器,并且只能为该呼叫发送一种消息.
There has been discussion as to various ways to achieve such a feature, but I'm unaware of any work having started or general agreement on a design. gRPC does support bidirectional streaming, which may get you some of what you need. With bidirectional streaming the client can respond to messages from server, but the client still calls the server and only one type of message can be sent for that call.
这篇关于gRPC连接的两端都可以接受方法调用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!