Update
This commit is contained in:
parent
e4014054d2
commit
db1ce8987d
|
|
@ -76,6 +76,10 @@ export default class SwitchController {
|
|||
this.onData(this.portGroups, this.status)
|
||||
}
|
||||
|
||||
private _handleTimeout() {
|
||||
this.onData(this.portGroups, this.status)
|
||||
}
|
||||
|
||||
private _waitFor(prompt: string, timeout = 5000): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
|
|
@ -109,8 +113,18 @@ export default class SwitchController {
|
|||
this.socket.on('data', (data) => this._handleData(data.toString()))
|
||||
resolve()
|
||||
})
|
||||
this.socket.on('close', () => this._handleClose())
|
||||
this.socket.on('error', (err) => this._handleError(err))
|
||||
this.socket.on('close', () => {
|
||||
this._handleClose()
|
||||
resolve()
|
||||
})
|
||||
this.socket.on('error', (err) => {
|
||||
this._handleError(err)
|
||||
resolve()
|
||||
})
|
||||
this.socket.on('timeout', () => {
|
||||
this._handleTimeout()
|
||||
resolve()
|
||||
})
|
||||
} catch (error: any) {
|
||||
console.log('[ERROR CONNECT SWITCH]:', error.message)
|
||||
reject(error)
|
||||
|
|
|
|||
Loading…
Reference in New Issue