[autobahncpp] Publishing complex data


I am using autobahn-cpp, and wish to publish complex data to a crossbar-io router, that will be received by an autobahn-js subscriber.

Here’s an example of the json representation of the data I wish to send in C++:

[{“object”: [1, 3.44, “hello_world”, false]}, {“object2”: null, “color”: “blue”, “x”: 4}]

I found out how to publish an array, using autobahncpp, but that required constructing a mspack::object. However, I am not sure if this is the right approach, because I couldn’t find documentation for it… The autobahncpp examples provided in the github repository only mention how to construct a publish message using std::tuple. Unfortunately, in my application the structure of the data, and the data types are dynamic, and the message needs to be constructed during the runtime (and hence std::tuple cannot really be used as far as i am aware).

std::array<int, 5> a{ 1, 2, 3, 4, 5};
msgpack::zone z;
msgpack::object obj(a, z);
autobahn::wamp_arguments args;
session->publish(“com.cpp.complex”, args);


I am not sure how the message needs to be constructed in general, before publishing, especially if the message types are not known. If you could point me in the right direction, that would be great (especially for constructing multiple key-value pairs in autobahncpp). An example, for sending the above complex message, using autobahncpp would be very appreciated.

Thanks and best regards