js/typescript websocket gzip数据解压(亲测可用)
代码
//依赖库
const zlib = require('zlib')
// client是websocket连接
client.onmessage = (e)=> {
console.log(e.data)
let data = Buffer.from(zlib.gunzipSync(e.data),'binary').toString('utf-8')
console.log(data)
}
结果
本文来自博客园,作者:HumorChen99,转载请注明原文链接:https://www.cnblogs.com/HumorChen/p/18039615