backgroundserver.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef BACKGROUNDSERVER_H
  2. #define BACKGROUNDSERVER_H
  3. #include <QObject>
  4. #include <QList>
  5. #include <QByteArray>
  6. #include <QJsonArray>
  7. #include <QJsonDocument>
  8. #include <QJsonObject>
  9. #include <QJsonValue>
  10. #include <QJsonParseError>
  11. #include "QtWebSockets/QWebSocketServer"
  12. #include "QtWebSockets/QWebSocket"
  13. #include <QThread>
  14. #include <QMutex>
  15. #include "simulationcontrol.h"
  16. //QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
  17. //QT_FORWARD_DECLARE_CLASS(QWebSocket)
  18. class BackgroundServer : public QObject
  19. {
  20. Q_OBJECT
  21. public:
  22. QThread *SimThread;
  23. SimulationControl *sim;
  24. QWebSocketServer *m_pWebSocketServer;
  25. QList<QWebSocket *> m_clients;
  26. explicit BackgroundServer(QObject *parent = nullptr, quint16 port = 80);
  27. virtual ~BackgroundServer();
  28. signals:
  29. void sigGetInit(QWebSocket *pSender, QJsonObject jsonObj);
  30. void sigGetLeadPost(QWebSocket *pSender, QJsonObject jsonObj);
  31. void sigGetTaskPlan(QWebSocket *pSender, QJsonObject jsonObj);
  32. void sigGetGlobalMap(QWebSocket *pSender, QJsonObject jsonObj);
  33. void sigGetPlatformTable(QWebSocket *pSender, QJsonObject jsonObj);
  34. void sigGetInstanceTable(QWebSocket *pSender, QJsonObject jsonObj);
  35. void sigGetRadarInstances(QWebSocket *pSender, QJsonObject jsonObj);
  36. void sigGetRadarParams(QWebSocket *pSender, QJsonObject jsonObj);
  37. void sigGetThaadInstances(QWebSocket *pSender, QJsonObject jsonObj);
  38. void sigSetThaadStyle(QWebSocket *pSender, QJsonObject jsonObj);
  39. void sigGetThaadParams(QWebSocket *pSender, QJsonObject jsonObj);
  40. void sigGetJammingInstances(QWebSocket *pSender, QJsonObject jsonObj);
  41. void sigGetJammingParams(QWebSocket *pSender, QJsonObject jsonObj);
  42. void sigSetJammingStyle(QWebSocket *pSender, QJsonObject jsonObj);
  43. void sigGetESMParams(QWebSocket *pSender, QJsonObject jsonObj);
  44. public slots:
  45. void onNewConnection();
  46. QJsonObject processJsonObj(QJsonObject objin);
  47. void processMessage(QString message);
  48. void socketDisconnected();
  49. void getInit(QJsonObject *obj);
  50. void getLeadPost(QJsonObject *obj);
  51. void getTaskPlan(QJsonObject *obj);
  52. void getGlobalMap(QJsonObject *obj);
  53. void getPlatformTable(QJsonObject *obj);
  54. void getInstanceTable(QJsonObject *obj);
  55. void getESMParams(QJsonObject *obj);
  56. void getESMData(QJsonObject *obj);
  57. void getNavParams(QJsonObject *obj);
  58. void setFreePost(QJsonObject *obj);
  59. void SlotReturnData(QWebSocket *pSender, QJsonObject *obj);
  60. };
  61. #endif // BACKGROUNDSERVER_H