ControlRequestHandler.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <QList>
  11. #include <QAbstractSocket>
  12. #endif
  13. class QTcpSocket;
  14. class QTcpServer;
  15. class ApplicationManagerBase;
  16. /** This Class is responsible for listening and getting new connections and
  17. * responding to text queries and commands from the socket. The original purpose
  18. * is to enable writing more reliable and better performing tests which launch
  19. * AP as a subprocess such as our python test modules.
  20. */
  21. class ControlRequestHandler : public QObject
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit ControlRequestHandler(ApplicationManagerBase* parent = 0);
  26. ~ControlRequestHandler();
  27. public slots:
  28. void GotConnection();
  29. void SocketStateUpdate(QAbstractSocket::SocketState newSocketState);
  30. void DataReceived();
  31. void Disconnected();
  32. void AssetManagerIdleStateChange(bool isIdle);
  33. protected:
  34. bool StartListening(unsigned short port = 0);
  35. void ReadData(QTcpSocket* incoming);
  36. private:
  37. QList<QTcpSocket*> m_listenSockets;
  38. QList<QTcpSocket*> m_idleWaitSockets;
  39. QTcpServer* m_tcpServer{ nullptr };
  40. ApplicationManagerBase* m_applicationManager{ nullptr };
  41. };