On Jul 21, 11:00 pm, Benedikt Hallinger
<b.hallin...@skyforcesystems.de> wrote:
> Hello,
> thank you very much for the ideas. Since i will have a unknowable ammount
> of Message types, extensions would be the way to go.
> Your were right with the assumption that i use Java.
> The "construct and send that message" stuff is not the problem, the main
> problem is, how i should parse the incoming ByteBuffer (or byte[]).
> I just cant figure out how i would be able to access the packets type.
> What im guesing now is, that since i will only send "Packet" messages (to
> stick to the threads examples) in the future, my lib will know that it only
> needs to deal with that "wrapper" type. From that i will access the payload
> using the extension methods?

Right, you would parse a Packet message.

> so the decoder part will work like this:
> - get byte array from wire
> - parse that data with the Packet-message types builder
> (mergeFrom(buffer)....)
> - now we have a Packet-object with the header fields set and the payload as
> extension
> - extract the payload object
> - push it to the appropriate handler
> But how exactly this would work with the above example? Is the "type" then
> transmitted as string?

The "type" is simply transmitted as a tag on the wire. The wire format
of extensions is just like the wire format of a regular field - the
difference is that the containing type (Packet) need not know about
the extension fields in the .proto definition. Instead, each payload
type that you might include will have a unique extension number. When
you include one of the payload messages in your program, it will
register its extensions of Packet. Then when a packet message is
parsed, if it sees a tag that is not defined in the .proto but is a
valid extension, it looks up the extension information and parses it
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to