Commit 572abe9a authored by Skye Yu's avatar Skye Yu

test: continue decode

parent 36982b4e
......@@ -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,17 @@ function Jensen(log) {
// 做一个回调,怎么样找到它呢?
blocks.push(result.data);
tryReceive();
if (self.decodeTimeout) clearTimeout(self.decodeTimeout);
self.decodeTimeout = setTimeout(function () {
tryDecode();
}, self.timewait);
if (self.onreceive) {
tryDecode();
try {
self.onreceive(totalBytes, continueDecode(result.data));
self.onreceive(totalBytes);
} catch (e) {
}
} else {
if (self.decodeTimeout) clearTimeout(self.decodeTimeout);
self.decodeTimeout = setTimeout(function () {
tryDecode();
}, self.timewait);
}
};
......@@ -787,7 +789,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