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

test: continue decode

parent 36982b4e
...@@ -31,7 +31,7 @@ declare class JensenType { ...@@ -31,7 +31,7 @@ declare class JensenType {
fileName: string, fileName: string,
length: number, length: number,
on?: (msg: Uint8Array | 'fail') => void, on?: (msg: Uint8Array | 'fail') => void,
onprogress?: (size: number, msg: Uint8Array | null) => void onprogress?: (size: number) => void
) => void; ) => void;
getFileBlock: ( getFileBlock: (
fileName: string, fileName: string,
......
...@@ -314,15 +314,17 @@ function Jensen(log) { ...@@ -314,15 +314,17 @@ function Jensen(log) {
// 做一个回调,怎么样找到它呢? // 做一个回调,怎么样找到它呢?
blocks.push(result.data); blocks.push(result.data);
tryReceive(); tryReceive();
if (self.decodeTimeout) clearTimeout(self.decodeTimeout);
self.decodeTimeout = setTimeout(function () {
tryDecode();
}, self.timewait);
if (self.onreceive) { if (self.onreceive) {
tryDecode();
try { try {
self.onreceive(totalBytes, continueDecode(result.data)); self.onreceive(totalBytes);
} catch (e) { } 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) ...@@ -787,7 +789,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
} }
}; };
this.onreceive = onprogress; this.onreceive = onprogress;
// Jensen.registerHandler(TRANSFER_FILE, handler); Jensen.registerHandler(TRANSFER_FILE, handler);
this.send(new Command(TRANSFER_FILE).body(fname)); 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