Close connections when window closed

Fixes #8
This commit is contained in:
Thomas Nordquist
2019-01-14 11:23:46 +01:00
parent 611fde13e2
commit ad78ca03d8
2 changed files with 10 additions and 0 deletions

View File

@@ -57,6 +57,11 @@ export class ConnectionManager {
connection.disconnect() connection.disconnect()
delete this.connections[hash] delete this.connections[hash]
} }
public closeAllConnections() {
Object.keys(this.connections)
.forEach(hash => this.removeConnection(hash))
}
} }
class UpdateNotifier { class UpdateNotifier {

View File

@@ -30,6 +30,11 @@ function createWindow () {
// Open the DevTools. // Open the DevTools.
// mainWindow.webContents.openDevTools() // mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('close', function () {
connectionManager.closeAllConnections()
})
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on('closed', function () { mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows // Dereference the window object, usually you would store windows