有 GRPC 客户端完整的使用例子吗?
Only grpc server sample found in this repository. Is the official grpc c++ library required?
libhv里集成了nghttp2实现http2协议,而grpc是基于http2的,所以理论上是可以实现grpc的,但是因为grpc绑定了protobuf,通过IDL文件自动生成序列化/反序列化代码,这步libhv还没有很好的集成。
目前可访问grpc服务的步骤为: 1、编译时带上nghttp2
./configure --with-nghttp2
make
2、请求协议采用http2,content-type设置为application/grpc
HttpRequest req;
req.http_major = 2;
req.http_minor = 0;
req.content_type = APPLICATION_GRPC;
3、请求body使用protobuf序列化
req.body = SerializeAsString(xxx);
HttpRequest req; req.http_major = 2; req.http_minor = 0; req.content_type = APPLICATION_GRPC; req.method = HTTP_POST; req.body = SerializeAsString(xxx);
HttpResponse res; hv::HttpClient client("0.0.0.0",12343); client.send(&req,&res);
Is there any progress? :)
Using the WebSocketClient::send(const char* buf, int len, enum ws_opcode opcode) method.
Example:
char* message = your protobuf serialize code....;
send(message, message.size(), WS_OPCODE_BINARY);