From 93b74ed3d0a56374d2976f9c08785faace6bcd15 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Tue, 22 Jul 2014 15:08:15 +0200 Subject: Drop the watchers concept, since the desiredProjectionSource essentially implies it --- src/server/mainwindow/mainwindow.cpp | 46 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index ab94535..1425640 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -711,7 +711,7 @@ void MainWindow::onButtonTutorToStudent() } // If "to" already watches "from" stop it - if (getSelectedFrame()->client()->isWatcher()) + if (getSelectedFrame()->client()->desiredProjectionSource() == getTutorFrame()->client()->id() ) { getSelectedFrame()->client()->setDesiredProjectionSource(NO_SOURCE); } @@ -1115,36 +1115,34 @@ void MainWindow::onVncClientStateChange(Client* client) if (client != NULL) { // VNC Client stopped -> remove from watchers - if (!client->isActiveVncClient()){ - // client->setDesiredProjectionSource(NO_SOURCE); + if (!client->isActiveVncClient()) + { + // Only unset a desired Projection source if it has not changed meanwhile + if (client->projectionSource() == client->desiredProjectionSource()) + client->setDesiredProjectionSource(NO_SOURCE); /* - * If nobody is watching the multicast stop VNC server - * If the past connection of this client is not the current - * _streamingSource then the manager has to have stopped it - * already. This is necessary for the race condition when a server + * If nobody is watching the VNC server of the pvsclient that + * stopped its vncclient stop it. (The _LAST_ vncserver, there + * may be a new one) + * This is necessary for the race condition when a server * is stopped and another started at the same time, since the new * server would be killed if all client disconnect before any of * the new connect. */ - if (client->projectionSource() == _streamingSource) - { - bool noWatchers = true; - for (QList::iterator it(_clientFrames.begin()); - it != _clientFrames.end(); ++it) - { - if ((*it)->client() != NULL) - { - if ((*it)->client()->isWatcher()) - noWatchers = false; + bool serverHasWatchers = false; + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + if ((*it)->client() != NULL) + if ((*it)->client()->desiredProjectionSource() == client->projectionSource()) { + serverHasWatchers = true; + break; } - } - if (noWatchers && _mode != Mode::Broadcast) - { - Client* c = getClientFromId(_streamingSource); - if (c != NULL) - c->stopVncServer(); - } + + if ( !(serverHasWatchers || _mode == Mode::Broadcast) ) + { + Client* c = getClientFromId(client->projectionSource()); + if (c != NULL) + c->stopVncServer(); } } } -- cgit v1.2.3-55-g7522