I have a messaging system over which I'm sending a set of different flatbuffer tables. The receiver end needs to be able to pick these off the wire and decode/typecast them to the appropriate type.
I can easily send a single type of message and read it at the other end but how do I detect multiple different types of messages from different schema files? Is there a magic number on the message that lets me identify the structure?
You can make the root table
contain a union
which contains the various message types. Or, if you prefer, you can declare a file_identifier
for each kind of FlatBuffer, and identify them that way.
Details: https://google.github.io/flatbuffers/md__schemas.html