Commit 996e96b0 authored by Skye Yu's avatar Skye Yu

test: continue decode

parent 691becf6
......@@ -31,7 +31,7 @@ declare class JensenType {
fileName: string,
length: number,
on?: (msg: Uint8Array | 'fail') => void,
onprogress?: (size: number, msg: Uint8Array | null) => void
onprogress?: (size: number) => void
) => void;
getFileBlock: (
fileName: string,
......
......@@ -314,15 +314,20 @@ function Jensen(log) {
// 做一个回调,怎么样找到它呢?
blocks.push(result.data);
tryReceive();
if (self.decodeTimeout) clearTimeout(self.decodeTimeout);
self.decodeTimeout = setTimeout(function () {
tryDecode();
}, self.timewait);
if (self.onreceive)
if (self.onreceive) {
const arr = [];
arr.push(result.data);
tryDecode(arr);
try {
self.onreceive(totalBytes, continueDecode(result.data));
self.onreceive(totalBytes);
} catch (e) {
}
} else {
if (self.decodeTimeout) clearTimeout(self.decodeTimeout);
self.decodeTimeout = setTimeout(function () {
tryDecode(blocks);
}, self.timewait);
}
};
// 持续解码
......@@ -342,7 +347,7 @@ function Jensen(log) {
return result && msg.id === TRANSFER_FILE ? msg.body : null;
}
const tryDecode = function () {
const tryDecode = function (blocks) {
// 一个容器,比单独任意一个小包要大一点儿,好像还差一点儿
let stime = new Date();
let buff = new ArrayBuffer(RECV_BUFF_SIZE * 2);
......
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