Mark
Mark

Reputation: 6494

protocol-buffers: send multiple messages of the same type

For example, I defined the following reply message in proto file:

syntax = "proto3";

message MyRequest {
   int32 id = 1;
}

message MyReply {
   int32 id = 1;
   int32 group = 2;
   string name = 3;
}

...

How can I tell in .proto file that MyReply can be received multiple times, i.e. if there is many objects that can be sent together?

Upvotes: 0

Views: 844

Answers (1)

Brits
Brits

Reputation: 18380

If I understand your question correctly it appears that using a repeated field would meet your needs:

message ReplyItem {
   int32 id = 1;
   int32 group = 2;
   string name = 3;
}

message MyReply {
   repeated ReplyItem items = 1;
}

Upvotes: 1

Related Questions