httpserver.h 650 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef HTTPSERVER_H
  2. #define HTTPSERVER_H
  3. #include <QObject>
  4. #include <QtCore>
  5. #include <QtNetwork>
  6. #include <QMutex>
  7. class HttpServer : public QObject
  8. {
  9. Q_OBJECT
  10. public:
  11. static HttpServer &instance();
  12. void run(const QHostAddress &address = QHostAddress::Any,const quint16 &port = 6122);
  13. signals:
  14. public slots:
  15. private slots:
  16. void newConnection();
  17. void readyRead();
  18. private:
  19. explicit HttpServer(QObject *parent = nullptr);
  20. ~HttpServer();
  21. Q_DISABLE_COPY(HttpServer)
  22. private:
  23. QTcpServer *m_httpServer;
  24. private:
  25. QByteArray mba;
  26. QMutex mMutex;
  27. public:
  28. QByteArray GetData();
  29. };
  30. #endif // HTTPSERVER_H