我在服务器上GZip一些JSON数据,通过Web套接字的Engine.IO实现发送它
function sendResourceDataToObserver(socket, data) {
zlib.gzip(data, function (_, result) {
socket.send(result);
});
}
并使用我使用Browserify(http://browserify.org/)
导入的ZLIB模块对其进行解压缩socket.on('message', function (data) {
zlib.gunzip(data, function(err, decoded) {
if (err) {
console.error(err);
}
console.log(decoded);
});
});
但是我得到了这个错误(“解码”显然是未定义的):
Error: invalid file signature:,�
at Error (<anonymous>)
at nb.i (http://localhost:5000/bundle.js:1994:184)
at Bb (http://localhost:5000/bundle.js:2000:424)
at http://localhost:5000/bundle.js:2000:338
at http://localhost:5000/bundle.js:1869:21
有什么想法吗?