Sending a byte array over WAMP

Hello,

I am seeking some help with sending a byte array as an argument in a WAMP publication. From reading the WAMP specification, it seems this is supported for both JSON and MessagePack serializers (using a “hack” to represent a base64 encoded string in JSON). I believe that Crossbar is able to translate byte arrays between different serialization formats.

However, I’m not sure how to code this using autobahn (-cpp or -python). In particular, what C++ or Python datatype should be passed to the autobahn serializer? I looked for an example of this use case but couldn’t find one.

Many thanks in advance for your help.

Hi,

the “hack” is using a string which starts with the \0 character, and then continues with the base64 encoded binary for the rest of the string. eg here is the code in python:

and tests (generally for the serializer stuff)

Hope this helps,
Cheers,
/Tobias

Thank you, that is helpful. I see that in Python I just need to put a bytestring in the args or kwargs of the publish call.

I tried to work out the equivalent in C++ by looking for the tests of autobahn-cpp, but I can’t find them on github…