Commit 691becf6 authored by Skye Yu's avatar Skye Yu

fix: continue decode function callback one-to-one

parent 99df522a
......@@ -320,13 +320,13 @@ function Jensen(log) {
}, self.timewait);
if (self.onreceive)
try {
self.onreceive(totalBytes, ciDecode(result.data));
self.onreceive(totalBytes, continueDecode(result.data));
} catch (e) {
}
};
// 持续解码
const ciDecode = (block) => {
const continueDecode = (block) => {
const buff = new ArrayBuffer(RECV_BUFF_SIZE * 2);
let bview = new Uint8Array(buff);
for (let k = 0; k < block.byteLength; k++) {
......@@ -338,7 +338,8 @@ function Jensen(log) {
} catch (err) {
console.error('ci decode', err);
}
return result ? result.message.body : null;
const msg = result.message;
return result && msg.id === TRANSFER_FILE ? msg.body : null;
}
const tryDecode = function () {
......@@ -784,7 +785,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
}
};
this.onreceive = onprogress;
Jensen.registerHandler(TRANSFER_FILE, handler);
Jensen.registerHandler(TRANSFER_FILE, handler);
this.send(new Command(TRANSFER_FILE).body(fname));
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment