summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/server/mainwindow/mainwindow.cpp63
-rw-r--r--src/server/net/client.h3
2 files changed, 55 insertions, 11 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index d0487d4..58da462 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -270,7 +270,8 @@ void MainWindow::tellClientCurrentSituation(Client* client)
client->lockScreen(true);
if (_mode == Mode::Broadcast){
- _watchers.insert(client->id(), client);
+ // _watchers.insert(client->id(), client);
+ client->setWatcher(true);
client->startVncClient(_streamingSource);
}
else if (_mode == Mode::LockedMulticast)
@@ -491,21 +492,40 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to)
{
// Set all clients as watchers
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
if ((*it)->client() != NULL && (*it)->client() != _streamingSource)
- _watchers.insert((*it)->client()->id(), (*it)->client());
+ {
+ // _watchers.insert((*it)->client()->id(), (*it)->client());
+ (*it)->client()->setWatcher(true);
+ }
+ }
}
else // mode != Mode::Broadcast
{
// If this is the first call in this mode clear the watchers
if ((mode == Mode::LockedMulticast && _mode != Mode::LockedMulticast)
|| (mode == Mode::Multicast && _mode != Mode::Multicast))
- _watchers.clear();
+ {
+ // _watchers.clear();
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
+ if ((*it)->client() != NULL)
+ (*it)->client()->setWatcher(false);
+ }
+ }
// If "to" already watches "from" stop it
- if (_watchers.contains(to->id()))
- _watchers.remove(to->id());
+ // if (_watchers.contains(to->id()))
+ if (getClientFromId(to->id())->isWatcher())
+ {
+ // _watchers.remove(to->id());
+ getClientFromId(to->id())->setWatcher(false);
+ }
else // list "to" as watcher
- _watchers.insert(to->id(), to);
+ {
+ // _watchers.insert(to->id(), to);
+ getClientFromId(to->id())->setWatcher(true);
+ }
}
// Set the mode
@@ -890,7 +910,8 @@ void MainWindow::onVncServerStateChange(Client* client)
// Ignore offline clients
if ( (*it)->client() != NULL)
{
- if (_watchers.contains((*it)->client()->id()))
+ // if (_watchers.contains((*it)->client()->id()))
+ if (getClientFromId((*it)->client()->id())->isWatcher())
{
// Unlock destination and connect VNCclient
(*it)->client()->lockScreen(false);
@@ -915,8 +936,16 @@ void MainWindow::onVncServerStateChange(Client* client)
else
{
// VNC server stopped on some client or failed to start - reset local pending projection information
- foreach (Client *c, _watchers) {
- c->stopVncClient();
+ // foreach (Client *c, _watchers) {
+ // c->stopVncClient();
+ // }
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
+ if ((*it)->client() != NULL)
+ {
+ if ((*it)->client()->isWatcher())
+ (*it)->client()->stopVncClient();
+ }
}
}
}
@@ -931,10 +960,22 @@ void MainWindow::onVncClientStateChange(Client* client)
{
// VNC Client stopped -> remove from watchers
if (!client->isActiveVncClient()){
- _watchers.remove(client->id());
+ // _watchers.remove(client->id());
+ getClientFromId(client->id())->setWatcher(false);
// If noboody is watching the multicast stop VNC server
- if (_watchers.isEmpty() && _mode != Mode::Broadcast)
+ // if (_watchers.isEmpty() && _mode != Mode::Broadcast)
+ // _streamingSource->stopVncServer();
+ bool noWatchers = true;
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
+ if ((*it)->client() != NULL)
+ {
+ if ((*it)->client()->isWatcher())
+ noWatchers = false;
+ }
+ }
+ if (noWatchers && _mode != Mode::Broadcast)
_streamingSource->stopVncServer();
}
}
diff --git a/src/server/net/client.h b/src/server/net/client.h
index d5942e8..1031838 100644
--- a/src/server/net/client.h
+++ b/src/server/net/client.h
@@ -37,9 +37,11 @@ public:
inline const bool isActiveVncClient() const { return _currentProjectionSource > 0; }
inline const bool isActiveVncServer() const { return _vncPort > 0; }
inline const bool isLocked() const { return _locked; }
+ inline const bool isWatcher() const { return _isWatcher; }
// Setters
inline void setTutor(bool enable){ _isTutor = enable; }
+ inline void setWatcher(bool enable){ _isWatcher = enable; }
//Send message stuff
void startVncServer();
@@ -65,6 +67,7 @@ private:
int _vncPort; // VNCserver state. Greater 0 -> active on this port. Equals 0 -> no server.
int _currentProjectionSource; // 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;