Skip to content

Commit

Permalink
Make ndt7 upload client simpler (#250)
Browse files Browse the repository at this point in the history
Simpler means fewer places for bugs to hide.
  • Loading branch information
pboothe authored Feb 6, 2020
1 parent 2f6a993 commit 8032c57
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions html/ndt7-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ onmessage = function (ev) {
sock.close()
return
}
const maxMessageSize = 16777216 /* (1<<24) */
const maxMessageSize = 16777216 /* = (1<<24) = 16MB */
if (data.length < maxMessageSize && data.length < (total - sock.bufferedAmount)/16) {
data = new Uint8Array(data.length * 2) // TODO(bassosimone): fill this message
}
Expand All @@ -38,11 +38,9 @@ onmessage = function (ev) {
})
previous = now
}
const drainSpeed = (total - sock.bufferedAmount) / (now - start)
const nextSleep = (sock.bufferedAmount / drainSpeed) / 2
setTimeout(function() {
uploader(sock, data, start, previous, total)
}, nextSleep)
setTimeout(
function() { uploader(sock, data, start, previous, total) },
0)
}
sock.onopen = function () {
const initialMessageSize = 8192 /* (1<<13) */
Expand Down

0 comments on commit 8032c57

Please sign in to comment.