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 +++++++++++++++++------------------- src/server/mainwindow/mainwindow.h | 1 - src/server/net/client.h | 14 +++-------- 3 files changed, 25 insertions(+), 36 deletions(-) (limited to 'src/server') 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(); } } } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 190f836..5de19c1 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -56,7 +56,6 @@ private: None } _mode; int _streamingSource; - QMap _watchers; QList _clientFrames; ListenServer *_listenServer; diff --git a/src/server/net/client.h b/src/server/net/client.h index 6dbb5bd..5e1b8b4 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -35,22 +35,15 @@ public: inline const QString& host() const { return _host; } inline const QString ip() const { return _socket->peerAddress().toString(); } inline const int id() const { return _id; } - inline const int desiredProjectionSource(){ return _desiredSource; } - inline const int projectionSource() const { return _projectionSource; } inline const bool isActiveVncClient() const { return _isActiveVncClient; } inline const bool isActiveVncServer() const { return _vncPort > 0; } inline const bool isLocked() const { return _locked; } - inline const bool isWatcher() const { return _desiredSource != 0; } - - + inline const int desiredProjectionSource(){ return _desiredSource; } + inline const int projectionSource() const { return _projectionSource; } // Setters inline void setTutor(bool enable){ _isTutor = enable; } - inline void setWatcher(bool enable){ _isWatcher = enable; } - inline void setDesiredProjectionSource(int id){ - qDebug() << "ID" <<_id << " new source " << _desiredSource; - _desiredSource = id; - } + inline void setDesiredProjectionSource(int id){_desiredSource = id;} //Send message stuff void startVncServer(); @@ -78,7 +71,6 @@ private: int _projectionSource; // The source the client was or is connected to (depends on _isActiveVncClient) bool _isActiveVncClient; // VNCclient state. indicating that the client is displaying a remote screen via VNC bool _isTutor; // Flag indicating that the client has been set as a tutor - bool _isWatcher; // Flag indicates that the client should watch to VNC Server. static int _clientIdCounter; -- cgit v1.2.3-55-g7522