Websocket send binary data


#1

In the documentation, there is a note about sending binary data, however, there are no details…
What I’m trying:
On client:

<script src="polyfill.min.js"></script>
<script src="adonis-ws.min.js"></script>
<script src="msgpack.browser.min.js"></script>
<script>
...
var msgPack = new adonis.MsgPack();
var ws = adonis.Ws('ws://localhost:3333').connect();
var ws.on('open', function() {
  var fileStream = ws.subscribe('file-stream');
  console.debug('Connection with WebSocket Server opened!');
  msgPack.encode(someBinaryData, (error, payload) => {
    if (error) {
      console.error(error);
    } else {
      fileStream.emit('stream', payload);
    }
  });
});
ws.on('close', function() {
  console.debug('Connection with WebSocket Server closed.');
});

And getting error:

Uncaught TypeError: adonis.MsgPack is not a constructor

What am I missing?


#2

Ended up just by converting binary data to base64 string.