Add input queue

pull/1/head
cpsdqs 7 years ago
parent a5aa536f89
commit 3d93cd3690
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 14
      js/term/connection.js

@ -19,9 +19,10 @@ module.exports = class TermConnection extends EventEmitter {
this.autoXoffTimeout = null
this.reconnTimeout = null
this.forceClosing = false
this.queue = []
try {
this.blobReader = new FileReader()
this.blobReader = new window.FileReader()
this.blobReader.onload = (evt) => {
this.onDecodedWSMessage(this.blobReader.result)
}
@ -90,12 +91,14 @@ module.exports = class TermConnection extends EventEmitter {
this.xoff = true
this.autoXoffTimeout = setTimeout(() => {
this.xoff = false
this.flushQueue()
}, 250)
break
case '+':
// console.log('xon');
this.xoff = false
this.flushQueue()
clearTimeout(this.autoXoffTimeout)
break
@ -143,7 +146,8 @@ module.exports = class TermConnection extends EventEmitter {
}
if (this.xoff) {
// TODO queue
console.log("Can't send, flood control.")
console.log("Can't send, flood control. Queueing")
this.queue.push(message)
return false
}
@ -159,6 +163,12 @@ module.exports = class TermConnection extends EventEmitter {
return true
}
flushQueue () {
console.log('Flushing input queue')
for (let message of this.queue) this.send(message)
this.queue = []
}
/** Safely close the socket */
closeSocket () {
if (this.ws) {

Loading…
Cancel
Save