Having multiple proto files with multiple messages within each. 
I am using Java and protobuf-java version 2.5.0

My processor class gets a String from a socket connection. This string I 
need to convert to a Message and forward it to a listener.

I need to create a message without knowing which message type/class I have.

Must be a better way than this? 
[CODE]
String text;
byte[] data = chunk.getBytes();

Message message = null;
try {
    message = Systems.Foo.parseFrom(data);
} catch (InvalidProtocolBufferException e) {

}

try {
    message = Systems.Bar.parseFrom(data);
} catch (InvalidProtocolBufferException e) {

}

try {
    message = Users.Logon.parseFrom(data);
} catch (InvalidProtocolBufferException e) {

}

return Message;
[/CODE]


This could be a double post. I posted this some time ago, but it did not 
appear on the group list.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to