I have been trying to use protocol buffers to communicate between two
processes over a network.  In doing so, I'm experiencing a problem
where I create a protocol buffer message and set it's extension, but
then when I receive it on the other process, the extension doesn't
register, it turns up as an unknown field.  I've gotten around it by
checking the unknown fields, but I'd prefer not to.  What could I be
doing wrong?

Here is basically what the .proto file looks like:
    message Message {
        optional string message = 1;
        extensions 10 to 100;
    }

    message Extension {
        extend Message {
            optional Extension extensionName = 10;
        }
        optional int32 data = 1;
    }

what the code on the sender side looks like:
    // init builders
    Message.Builder msgBuilder = Message.newBuilder();
    Extension.Builder extensionBuilder = Extension.newBuilder();
    // set extension
    msgBuilder.setExtension(Extension.extensionName,
extensionBuilder.setData(1).build());
    // build, convert to a byte array, and send
    send(msgBuilder.build().toByteArray());

and on the receiver side:
    // receive the message
    byte[] buffer = receive();
    // parse the message from the array
    Message msg = Message.parseFrom(buffer);
    // check if message has the extension
    if(msg.hasExtension(Extension.ExtensionName)) // this returns
false = (
        // blah blah blah

Thanks for any insight!
--~--~---------~--~----~------------~-------~--~----~
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