Commit 28c636a7 authored by martin hou's avatar martin hou

fix: 调整tryReceive方法的轮回迭代

parent f9dd0478
......@@ -437,6 +437,7 @@ function Jensen(log, conn) {
const tryReceive = function () {
if (device)
{
// console.log('trace', device);
device.transferIn(2, RECV_BUFF_SIZE).then((r) => {
Logger.save?.('jensen', 'tryReceive', r?.data);
......@@ -446,9 +447,9 @@ function Jensen(log, conn) {
// console.log('tryReceive error', e)
// if (!channelHealthy) self.onerror?.(e);
Logger.error('jensen', 'receive', String(e));
tryReceive();
});
}
tryReceive();
};
const read_int = function (a, b, c, d) {
......@@ -469,13 +470,10 @@ function Jensen(log, conn) {
// 做一个回调,怎么样找到它呢?
blocks.push(result.data);
if (self.decodeTimeout) clearTimeout(self.decodeTimeout);
self.decodeTimeout = setTimeout(function () {
tryDecode();
}, self.timewait);
self.decodeTimeout = setTimeout(function () { tryDecode(); }, self.timewait);
if (self.onreceive) {
try { self.onreceive(totalBytes); } catch (e) {}
}
tryReceive();
};
const tryDecode = function () {
......@@ -1108,7 +1106,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
Logger.info('jensen', 'transfer', percent + '%');
if (percent > 0 && percent < 100)
{
// if (!(k in self._progress_report)) setTimeout(() => onprogress?.(recvBytes), 0);
if (!(k in self._progress_report)) setTimeout(() => onprogress?.(recvBytes), 0);
self._progress_report[k] = true;
}
if (percent >= 100 && !(k in self._progress_report))
......
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