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