Catch exception on failed WS command to avoid interface from breaking (#3858)
* Catch exception on failed WS command to avoid interface from breaking * Fix linter
This commit is contained in:
parent
8ded5838a8
commit
68f03d3fb1
1 changed files with 10 additions and 6 deletions
|
@ -172,13 +172,17 @@ class WSClient {
|
|||
}
|
||||
|
||||
sendCommand(command: WSCommand): void {
|
||||
if (this.client !== null) {
|
||||
const {action, ...data} = command
|
||||
this.client.sendMessage(this.clientPrefix + action, data)
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (this.client !== null) {
|
||||
const {action, ...data} = command
|
||||
this.client.sendMessage(this.clientPrefix + action, data)
|
||||
return
|
||||
}
|
||||
|
||||
this.ws?.send(JSON.stringify(command))
|
||||
this.ws?.send(JSON.stringify(command))
|
||||
} catch (e) {
|
||||
Utils.logError(`WSClient failed to send command ${command.action}: ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
sendAuthenticationCommand(token: string): void {
|
||||
|
|
Loading…
Reference in a new issue