On Wednesday, January 23, 2013 7:53:36 PM UTC+8, Barzo wrote:
>
> Hi,
>
> I'm trying to implement a system like described 
> here<http://blog.florindinu.ro/posts/message-dispatching-in-c-part-0-problem.html>
>  where 
> I have a Type List of Messages.
> Now, when I receive a message from an endpoint, I need a way to retrieve 
> the message opCode (which is a filed contained in all messages) to build my 
> message template class.
>
> My .proto is like this:
>
> enum EMessages
> {
>   E_MSG_METHOD_CONNECT  = 0x8001;
>   E_MSG_EVENT_CONNECT   = 0xA001;
>   ....
> }
>
> message MsgHeader
> {
>   required google.protobuf.FileDescriptorSet  proto_files = 1;
>   required long  sessionRef    = 3;
>   optional long   transactionId = 4 [default = 0];
>   optional long   status        = 5 [default = 0];
> }
>
> message MSG_METHOD_CONNECT
> {
>   optional EMessages    opCode = 1 [default = E_MSG_METHOD_CONNECT];
>   required MsgHeader    header = 2;
>   ... other fields ...
> }
>
> message MSG_EVENT_CONNECT
> {
>   optional EMessages    opCode = 1 [default = E_MSG_EVENT_CONNECT];
>   required MsgHeader    header = 2;
>   ... other fields ...
> }
>
> So each message contains the opCode field.
> Is there a way to retrieve the opCode value from a received stream?
>
So you want to use the opCode value to distinguish which message is sent?
The common practice is that you always send the sam message over the wire, 
like this:
message TheOneMessageSentOverTheWire {
  optional EMessages opCode = 1;
  optional MSG_METHOD_CONNECT message1 = 2;
  optional MSG_EVENT_CONNECT message 2 = 3;
  ...
}

 

>
> Regards,
> Daniele.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to