7.2.5. FlatBuffers: Monster
FlatBuffers “is an efficient cross platform serialization library for C++, C#, C, Go, Java, Kotlin, JavaScript, Lobster, Lua, TypeScript, PHP, Python, Rust and Swift. It was originally created at Google for game development and other performance-critical applications.” eCAL has implemented flatbuffer serialization on top of the binary publisher and subscriber API, such that users can conveniently send flatbuffer objects. Currently, the eCAL FlatBuffers Message API is only available for C++.
Let’s start with a simple example of sending a monster object using FlatBuffers.
7.2.5.1. Monster FlatBuffers
As the sender and receiver need the same .fbs
files, we place them in a separate directory next to the source directories for the sender and the receiver.
Let’s start with the monster/monster.fbs
file!
|fa-folder-open| Monster FlatBuffers File
└─ |fa-file-alt| monster.fbs
7.2.5.2. Monster Publisher
|fa-folder-open|
└─ |fa-folder-open| C++
└─ |fa-file-alt| monster_send.cpp
7.2.5.3. Monster Subscriber
|fa-folder-open|
└─ |fa-folder-open| C++
└─ |fa-file-alt| monster_receive.cpp