mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-06 14:10:53 +03:00
added delay when ws.bufferedAmount is high
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { arrayToB64, b64ToArray } from './utils';
|
import { arrayToB64, b64ToArray, delay } from './utils';
|
||||||
|
|
||||||
function post(obj) {
|
function post(obj) {
|
||||||
return {
|
return {
|
||||||
@@ -162,6 +162,9 @@ async function upload(
|
|||||||
onprogress([Math.min(streamInfo.fileSize, size), streamInfo.fileSize]);
|
onprogress([Math.min(streamInfo.fileSize, size), streamInfo.fileSize]);
|
||||||
size += streamInfo.recordSize;
|
size += streamInfo.recordSize;
|
||||||
state = await reader.read();
|
state = await reader.read();
|
||||||
|
while (ws.bufferedAmount > streamInfo.recordSize * 2) {
|
||||||
|
await delay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const footer = new Uint8Array([0]);
|
const footer = new Uint8Array([0]);
|
||||||
ws.send(footer);
|
ws.send(footer);
|
||||||
|
|||||||
Reference in New Issue
Block a user