On Tue, Oct 19, 2010 at 8:17 AM, jon.mithe <jon.mi...@gmail.com> wrote:

> Hi,
>
> I am thinking about using the protocol buffers over XML for a server I
> am writing.
>
> Is there a way to pick up on what message type / descriptor it is
> without using the specific compiled .proto implementation?
>

No.  By design, no type information is included in the message, and the
encoding is so dense that it is often impossible to reliably distinguish the
type.


> The server needs to be very flexible / modular.  So I was hoping to
> develop modules of functionality, each defining there own .proto
> messages.  Then have a simple incoming connection which can
> effectively inspect /  pass these messages onto a matching handler in
> whatever module owns that message.
>

You may want to create an "envelope" message type which helps your server
route messages without having to parse the message contents.  Example:

  message Envelope {
    optional string destination = 1;
    optional bytes real_message = 2;
  }

The server receives Envelopes and sends them to the correct module based
only on "destination".  The module then knows how to parse its own messages.


> I can include descriptor/typing information in the stream to the
> server to match the handler, but was hoping / thought the google
> protocol library may have some ways to poke at the messages -- have
> not found any yet.
>

Yes, you can do that.  See:
http://code.google.com/apis/protocolbuffers/docs/techniques.html#self-description


> Been reading about the reflection on Messages, but seems like this
> just for a parsed message to inspect it in a generic / abstract way,
> i.e. not like java reflection which is more what I need to id a
> message but I parse it properly.
>

Once you have a Descriptor, you can construct a DynamicMessage and parse
into that.  You can then use protobuf reflection on the DynamicMessage.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to