revert: back to working simple send, bump to 1.0.16
Deploy loadtest / validate (push) Waiting to run
Deploy loadtest / validate (push) Waiting to run
This commit is contained in:
+9
-25
@@ -209,43 +209,27 @@ function uploadFileWS(url, f, idx) {
|
|||||||
ws.binaryType = 'arraybuffer';
|
ws.binaryType = 'arraybuffer';
|
||||||
|
|
||||||
ws.onopen = function () {
|
ws.onopen = function () {
|
||||||
ws.bufferedAmountLowThreshold = CHUNK;
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
function sendNext() {
|
|
||||||
var end = Math.min(offset + CHUNK, f.size);
|
|
||||||
reader.readAsArrayBuffer(f.file.slice(offset, end));
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
ws.send(e.target.result);
|
ws.send(e.target.result);
|
||||||
offset += CHUNK;
|
offset += CHUNK;
|
||||||
|
if (offset < f.size) {
|
||||||
var pct = Math.round(offset / f.size * 100);
|
var pct = Math.round(offset / f.size * 100);
|
||||||
if (pct - lastProgress >= 5) {
|
if (pct - lastProgress >= 10) {
|
||||||
lastProgress = pct;
|
lastProgress = pct;
|
||||||
f.progress = pct;
|
f.progress = pct;
|
||||||
renderTable();
|
renderTable();
|
||||||
}
|
}
|
||||||
|
readNext();
|
||||||
if (offset >= f.size) {
|
|
||||||
// Когда буфер опустеет — шлём DONE
|
|
||||||
function checkDone() {
|
|
||||||
if (ws.bufferedAmount === 0) {
|
|
||||||
ws.send('DONE');
|
|
||||||
} else {
|
} else {
|
||||||
setTimeout(checkDone, 50);
|
ws.send('DONE');
|
||||||
}
|
|
||||||
}
|
|
||||||
checkDone();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
function readNext() {
|
||||||
ws.addEventListener('bufferedamountlow', function () {
|
var end = Math.min(offset + CHUNK, f.size);
|
||||||
if (offset < f.size) sendNext();
|
reader.readAsArrayBuffer(f.file.slice(offset, end));
|
||||||
});
|
}
|
||||||
|
readNext();
|
||||||
sendNext();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onmessage = function (e) {
|
ws.onmessage = function (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user