documentaion have one simple example "serialization-unserialization" with one packet. (i not found more examples)
if i have a many structs of packet, i need use union to this? or this bad idea?
how i need verify income packets, before use it in program?
method Verify - all i need to validate packet? (struct is correct, fields are permissible)
include "body1.fbs";
include "body2.fbs";
union PacketBody {
body1,
body2
}
table Packet {
body: PacketBody
}
root_type Packet;
auto request = Packet::GetPacket(&buf);
auto ver = new flatbuffers::Verifier(buf, len);
if(request->Verify(*ver) {
//good ?
auto body = request->body();
auto body_type = request->body_type();
map[body_type](body);
} else {
//wrong packet
}