SignalingServer.h 746 B

1234567891011121314151617181920212223242526272829
  1. #ifndef SIGNALINGSERVER_H
  2. #define SIGNALINGSERVER_H
  3. #include <QAbstractSocket>
  4. #include <QByteArray>
  5. #include <QHostAddress>
  6. #include <QObject>
  7. #include <QString>
  8. class QWebSocketServer;
  9. class QWebSocket;
  10. class SignalingServer : public QObject {
  11. Q_OBJECT
  12. public:
  13. explicit SignalingServer(QObject *parent = nullptr);
  14. bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
  15. private slots:
  16. void onNewConnection();
  17. void onDisconnected();
  18. void onWebSocketError(QAbstractSocket::SocketError error);
  19. void onBinaryMessageReceived(const QByteArray &message);
  20. void onTextMessageReceived(const QString &message);
  21. private:
  22. QWebSocketServer *server;
  23. QMap<QString, QWebSocket *> clients;
  24. };
  25. #endif // SIGNALINGSERVER_H