I'm trying to handle some generic Message values within a wrapping protocol buffer (with nodejs):
message MessageWrapper {
string id = 1;
google.protobuf.Any wrapped_message = 2;
....
}
as part of this, I have to pack() the Any:
const wrapper = new MessageWrapper();
const wrappedMessage = new Any();
wrappedMessage.pack(msg.serializeBinary(), msgType);
The heart of the problem is the msgType. If I was using java, I could get the msg.getDescriptorForType(), but javascript doesn't seem to support that.. level of self description. Outside of manually supplying the string type url, how does one get it?
Addendum: To be honest I'm not sure what the msgType of pack() is used for. It seems I can put any string value in there and packing and unpacking seem to work fine. What's it for?