From 0a1ea46b8d2c4da6e89bfb1a1e529984d6e363a0 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 21 Jun 2017 08:40:47 +0200 Subject: [PATCH] fix projector reconnecting if websocket is closed --- openslides/core/static/js/core/projector.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/openslides/core/static/js/core/projector.js b/openslides/core/static/js/core/projector.js index 9c3380695..5b4600a29 100644 --- a/openslides/core/static/js/core/projector.js +++ b/openslides/core/static/js/core/projector.js @@ -9,9 +9,24 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core']) .constant('REALM', 'projector') .run([ + '$http', 'autoupdate', - function (autoupdate) { + 'DS', + function ($http, autoupdate, DS) { autoupdate.newConnect(); + + // If the connection aborts, we try to ping the server with whoami requests. If + // the server is flushed, we clear the datastore, so the message 'this projector + // cannot be shown' will be displayed. Otherwise establish the websocket connection. + autoupdate.registerRetryConnectCallback(function () { + return $http.get('/users/whoami').then(function (success) { + if (success.data.user_id === null && !success.data.guest_enabled) { + DS.clear(); + } else { + autoupdate.newConnect(); + } + }); + }); } ])