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