0

我在客户端有一个 proto 文件,在服务器中有一个,但是客户端 protobuf 中特定属性的字段编号在服务器 proto 中必须相同。

message Foo_client {
    string foo_has = 1;
    string bar_has = 3;
 }

message Foo_server {
    string bar_true = 1;
    string foo_true = 2;
    string bar_has = 3;
 }

since in server proto file attribute "bar_has" had tag=3 ,so in client it has to be 3  
why?? and is there any other solution that we can use to remove this ambiguity
4

1 回答 1

0

请更清楚您的查询。据我所知,您的服务器和客户端没有两个单独的原型文件。定义 proto 文件的重点是在服务器和客户端之间定义一致的握手。

您不能跳过一个数字,因为它是递增的。您应该定义的结构应该基于请求/响应而不是服务器/客户端。

于 2020-05-14T11:36:27.683 回答