The blob object-binary buffer

He has made a websocket of the Project, and then a third-party interfaces, third-party interface has a node case, case by websocket returned data buffer is a direct object, and then through a third party libraries pako, decompress.

      But the client, the returned data is binary data blob, then how will it be decompression to the client it?

     Finally, successful resolution through the renderer objects:

var render = new FileReader();
render.onloadend = function () {
    var ms = pako.inflate(render.result, {
        to: 'string'
    });
    var msg = JSON.parse(ms);
    if (msg.ping) {
        that.websocket.send(JSON.stringify({
            pong: msg.ping
        }));
    } else if (msg.tick) {
        var attr = msg.ch.split(".")[1];
        document.querySelector("." + that.name + attr).innerHTML = parseFloat(msg.tick.close);
    }
};
render.readAsBinaryString(e.data);


Published 31 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_38694034/article/details/79292404