Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
serverconnection.h
Go to the documentation of this file.
1 #ifndef _PVSSERVERCONNECTION_H_
2 #define _PVSSERVERCONNECTION_H_
3 
4 #include <QSslSocket>
5 #include "../../shared/networkmessage.h"
6 #include "../connectwindow/connectwindow.h"
7 
8 class BlankScreen;
9 
10 class ServerConnection : public QObject
11 {
12  Q_OBJECT
13 
14 private:
15  QSslSocket *_socket;
19  int _authed;
22  qint64 _lastData;
23 
26  QString _passwd;
27  QByteArray _myChallenge;
28  QByteArray _sessionName;
29  QByteArray _certHash;
30 
31  void handleMsg();
32 
33  void checkLocalConnection();
34 
35 public:
36  ServerConnection(const QString& host, quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect);
37  void disconnectFromServer();
38  ~ServerConnection() override;
39  inline bool isConnected() const
40  {
41  return _socket != nullptr && _socket->state() == QAbstractSocket::ConnectedState;
42  }
43 
44  QString getPeerAdress() const { return _socket->peerAddress().toString(); }
45 
47  if (_isLocalConnection == -1) {
49  }
50  return _isLocalConnection == 1;
51  }
52 
53  void sendMessage(NetworkMessage& message);
54  void sendAttention(bool on);
55 
56 protected:
57  void timerEvent(QTimerEvent *event) override;
58 
59 private slots:
60  void sslErrors(const QList<QSslError> & errors); // triggered for errors that occur during SSL negotiation
61  void sock_dataArrival(); // triggered if data is available for reading
62  void sock_closed(); // triggered if the socket is closed
63  void sock_error(QAbstractSocket::SocketError errcode); // triggered if an error occurs on the socket
64  void sock_connected(); // triggered if the connection is established and ready to use
65 
66  void onVncServerStartStop(int port, const QString &ropass, const QString &rwpass); // triggered if the local vnc server was started
67 
68 public slots:
69  void onVncViewerStartStop(bool started, int clientId);
70 
71 signals:
72  void openVnc(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb);
73  void closeVnc();
75  void disconnected(ServerConnection* connection);
76  void attentionChanged(bool state);
77 };
78 
79 #endif
QString getPeerAdress() const
QByteArray _sessionName
QSslSocket * _socket
QByteArray _expectedFingerprint
~ServerConnection() override
void stateChange(ConnectWindow::ConnectionState state)
void sendMessage(NetworkMessage &message)
Send the given message to the server.
BlankScreen * _blank
NetworkMessage _toServer
void disconnectFromServer()
Disconnect from current server.
void attentionChanged(bool state)
NetworkMessage _fromServer
void disconnected(ServerConnection *connection)
void onVncServerStartStop(int port, const QString &ropass, const QString &rwpass)
This slot is triggered by the vnc server runner once the external VNC server was succesfully started...
void timerEvent(QTimerEvent *event) override
QByteArray _certHash
bool isConnected() const
void sock_error(QAbstractSocket::SocketError errcode)
void sslErrors(const QList< QSslError > &errors)
An ssl error happened.
ServerConnection(const QString &host, quint16 port, const QByteArray &sessionName, const QByteArray &certHash, bool autoConnect)
void openVnc(const QString &host, int port, const QString &passwd, bool ro, bool fullscreen, const QString &caption, const int clientId, const QByteArray &rawThumb)
void handleMsg()
Handles an incoming message by the server.
void onVncViewerStartStop(bool started, int clientId)
This slot is triggered once the internal VNC viewer has started or stopped displaying a VNC stream...
QByteArray _myChallenge
void sendAttention(bool on)