Madhav, When you receive a raw string of bytes containing a message, you must first know the type of the message before you can parse/deserialize it. For example, with C++, you must first instantiate a message of the appropriate type, and then parse the bytes into the newly instantiated message object. You cannot make use of the reflection API until after you have a message object. Thus, if you are going to send multiple message types over a single connection, the recommended approach seems to be to define a 'MessageContainer' type which you can then extend with fields to hold all your other message types.
Using this approach, you _always_ send a message container object, you just change which message fields you put into the message container. When you receive a message, you know that it is a message container, so you can parse the bytes into a MessageContainer object. You can then either check for the presence of specific fields in the container object, or you can retrieve and iterate over the list of populated extension fields. This approach has been discussed a few times on this list. Try searching the message archive for more details: A couple applicable posts: http://groups.google.com/group/protobuf/browse_thread/thread/79c4c680936a5aee/bdb7cdd52fe65426?lnk=gst&q=container#bdb7cdd52fe65426 http://groups.google.com/group/protobuf/browse_thread/thread/abed52fb98f68a01/a829bb4bf948ccec?lnk=gst&q=container#a829bb4bf948ccec(You can note that this is the message where someone else was kind enough to explain this same concept to me) Ex On Sat, Jan 16, 2010 at 1:08 AM, mancha <madhavan...@gmail.com> wrote: > Hi, > > What would the recommended way to determine which message is being > received be in an environment where different messages are sent over > the same connection? > > Is the reflection API the recommended way to go, even if the apps > are performance critical? > > Thanks, > Madhav. > > > -- > 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<protobuf%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > > >--
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.