2014-01-26 73 views
0

嗨,大家好,我想知道是否有辦法發送對象拋出協議緩衝區列表?當我讀這個頁面時,它說你可以,但你需要自己編寫代碼。我實際上無法理解這個需要什麼,所以如果有人能夠幫助它會是好的。 這裏是tutorial用協議緩衝區發送已定義對象的列表

回答

1

假設你定義了一個名爲Foo對象,

message Foo { 
    ... 
} 

如果你想發送美孚的列表,你可以把它在另一個消息重複的字段,

message FooList { 
    repeated Foo foos = 1; 
} 

您可以檢查language guide

You specify that message fields are one of the following: 

required: a well-formed message must have exactly one of this field. 
optional: a well-formed message can have zero or one of this field (but not more than one). 
repeated: this field can be repeated any number of times (including zero) in a well-formed message. The order of the repeated values will be preserved. 
+0

是的,這是正確的回答我在發佈問題後發現它,lol:D – Adelin