fix projector reconnecting if websocket is closed

This commit is contained in:
FinnStutzenstein 2017-06-21 08:40:47 +02:00
parent 573fc4da57
commit 0a1ea46b8d

View File

@ -9,9 +9,24 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core'])
.constant('REALM', 'projector') .constant('REALM', 'projector')
.run([ .run([
'$http',
'autoupdate', 'autoupdate',
function (autoupdate) { 'DS',
function ($http, autoupdate, DS) {
autoupdate.newConnect(); 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();
}
});
});
} }
]) ])