I would like to include a protocol definition file in another protocol file. For example:
// base.proto: message P_EndPoint { required int32 id = 1; required string host = 2; required int32 port = 3; }
Then in another file:
communication.proto: // somehow include `base.proto' // ... message P_CommunicationProtocol { required CP_MessageType type = 1; optional int32 id = 2; optional P_EndPoint identity = 3; repeated P_EndPoint others = 4; } // ...
(Note: developers.google.com is not available in my locale)
A . proto file is similar to a JSON file in that it represents structured data, but you can run a compiler on the . proto file to generate code that can read and write the data in the programming language of your choice. For more information about protocol buffers, see Protocol Buffer Developer Guide on Google's site.
namespace google::protobuf. RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields. These classes are very similar to STL's vector, but include a number of optimizations found to be useful specifically in the case of Protocol Buffers.
The Protobuf is a binary transfer format, meaning the data is transmitted as a binary. This improves the speed of transmission more than the raw string because it takes less space and bandwidth. Since the data is compressed, the CPU usage will also be less.
By default, gRPC uses Protocol Buffers, Google's mature open source mechanism for serializing structured data (although it can be used with other data formats such as JSON). Here's a quick intro to how it works.
import "myproject/base.proto";
Docs: http://developers.google.com/protocol-buffers/docs/proto#other
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With