Hi,

I was wondering if it was possible to extract the contents of a
serialized string without knowing ahead of time what kind of message
it is?

For example: I'm using tcp to send data back and fourth.  On one side
I create a message and serialize the data, and on the receiving side I
'ParseFromString' and check the information.  However, I have
different types of messages being sent so the receiving side has no
idea what it is actually getting.

example .proto file [messages actually contain field, taken out for
simplicity] which creates 'dtm_pb2' after compiling

package dtm;
message ping {
}
message statusUpdate {
}
message findWorker {
}

so in my code on the receiving end I have:
msg = dtm_pb2()
msg.ParseFromString(message)

this gives an error.

Is there any way to initialize the msg variable and extract the
information??
If I knew what kind of message it was I could always use:
msg = dtm_pb2.statusUpdate()
msg.ParseFromString(message)
and this would work fine, but this is no a viable solution for me.

thanks,

Nima
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to