subpackageSend(buffer) { let length = buffer.byteLength; let count = Math.ceil(length / 20); //最多执行 count 次 for (let i = 0; i < count; i++) { console.log("进行第" + i + '次数据写入'); let TempBuffer; if (((i + 1) * 20) < length) { TempBuffer = buffer.slice(i * 20, (i + 1) * 20); } else { TempBuffer = buffer.slice(i * 20, length); } setTimeout(() => { this.send(TempBuffer); }, 250 * i) //250秒延迟,防止错乱 } },
标签:count,20,buffer,TempBuffer,length,let,分包 From: https://www.cnblogs.com/fhysy/p/16966065.html