Skip to content

Commit

Permalink
Fix ack flag after remote disconnected
Browse files Browse the repository at this point in the history
- Fix double Tuya TCP channels
  • Loading branch information
haimkastner committed Dec 11, 2021
2 parents 9e21396 + 10521be commit df3aa8c
Show file tree
Hide file tree
Showing 2 changed files with 479 additions and 461 deletions.
3 changes: 3 additions & 0 deletions backend/src/business-layer/remoteConnectionBl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,14 @@ export class RemoteConnectionBl {
this.webSocketClient = new WebSocketClient(3000, false);

this.webSocketClient.on('open', () => {
this.ackPongReceived = true;
this.remoteConnectionStatus = 'connectionOK';
logger.info(`[RemoteConnectionBl.connectToRemote][on-open] Ws channel to ${remoteSettings.host} opened successfully`);
});

this.webSocketClient.on('message', async (rawRemoteMessage: string) => {
try {
this.ackPongReceived = true;
await this.onRemoteServerMessage(rawRemoteMessage);
} catch (error) {
logger.error(`[RemoteConnectionBl.connectToRemote][on-message] Ws message parsing & handling filed row message: ${rawRemoteMessage}\n error ${error.message || JSON.stringify(error)}`);
Expand Down Expand Up @@ -438,6 +440,7 @@ export class RemoteConnectionBl {
}

private async OnArkOk() {
logger.info('[RemoteConnectionBl][OnArkOk] Remote connection sent pong')
this.ackPongReceived = true;
this.remoteConnectionStatus = 'connectionOK';
}
Expand Down
Loading

0 comments on commit df3aa8c

Please sign in to comment.