Skip to content

Commit

Permalink
fix: handle api reconnections
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozwiaczek committed Sep 15, 2021
1 parent 4a21a8b commit 87be799
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/device/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dotenv/config';

import ngrok from 'ngrok';
import socketClient from 'socket.io-client';

import actionExecutor from './actions/actionExecutor';
Expand Down Expand Up @@ -45,11 +46,13 @@ socket.on('connect', () => {
if (!deviceInitialisedOnConnect) {
socket.emit(WebSocketEvent.DEVICE_TURNED_ON);
initMotion();
void initNgrok(socket);
deviceInitialisedOnConnect = true;
}

void initNgrok(socket);
});

socket.on('disconnect', () => {
void ngrok.disconnect();
logger.log(`API disconnected`);
});

0 comments on commit 87be799

Please sign in to comment.