Flatbuffers - Generate type id

301 Views Asked by At

I am looking at Flatbuffers for one of my projects in order to serialize and exchange messages between a client and a server written in two different languages. I want some kind of unique identifier in order to identify each message when receiving them. I cant seem to figure out how I can achieve this.

My question is there for. Is it possible to get flatc to generate an unique ID for each struct? And if that is the case. What's the syntax for doing so?

1

There are 1 best solutions below

0
On

You want to use either a union (if you can specify all message types in a single schema), or use the file_identifier feature (if you want an open-ended way to recognize different kinds of buffers).

See the tutorial for details: https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html