From a1e95dc012616375659388c497bc7a8a0cc42b62 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Tue, 15 Dec 2020 19:03:58 +0100 Subject: [PATCH] Close remote app on error or disconnect --- clapper_src/webClient.js | 4 +++- clapper_src/widgetRemote.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/clapper_src/webClient.js b/clapper_src/webClient.js index a1397f45..938586dc 100644 --- a/clapper_src/webClient.js +++ b/clapper_src/webClient.js @@ -57,7 +57,7 @@ class ClapperWebClient extends Soup.Session } if(!connection) - return; + return this.passMsgData('close'); connection.connect('message', this._onWsMessage.bind(this)); connection.connect('closed', this._onWsClosed.bind(this)); @@ -78,5 +78,7 @@ class ClapperWebClient extends Soup.Session _onWsClosed(connection) { debug('closed WebSocket connection'); + + this.passMsgData('close'); } }); diff --git a/clapper_src/widgetRemote.js b/clapper_src/widgetRemote.js index 79a95961..ba0cddfe 100644 --- a/clapper_src/widgetRemote.js +++ b/clapper_src/widgetRemote.js @@ -9,5 +9,18 @@ class ClapperWidgetRemote extends Gtk.Grid super._init(); this.player = new PlayerRemote(); + this.player.webclient.passMsgData = this.receiveWs.bind(this); + } + + receiveWs(action, value) + { + switch(action) { + case 'close': + let root = this.get_root(); + root.run_dispose(); + break; + default: + break; + } } });