diff --git a/backend/src/index.ts b/backend/src/index.ts index 9e78efb..e37aadd 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -57,6 +57,11 @@ export class ConnectionManager { connection.disconnect() delete this.connections[hash] } + + public closeAllConnections() { + Object.keys(this.connections) + .forEach(hash => this.removeConnection(hash)) + } } class UpdateNotifier { diff --git a/electron.js b/electron.js index c2556ae..e298cbb 100644 --- a/electron.js +++ b/electron.js @@ -30,6 +30,11 @@ function createWindow () { // Open the DevTools. // mainWindow.webContents.openDevTools() + // Emitted when the window is closed. + mainWindow.on('close', function () { + connectionManager.closeAllConnections() + }) + // Emitted when the window is closed. mainWindow.on('closed', function () { // Dereference the window object, usually you would store windows