ApplicationServer.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 <QTcpServer>
  11. #include <native/utilities/AssetUtilEBusHelper.h>
  12. #endif
  13. /** This Class is responsible for listening and getting new connections
  14. */
  15. class ApplicationServer
  16. : public QTcpServer,
  17. public ApplicationServerBus::Handler
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit ApplicationServer(QObject* parent = 0);
  22. virtual ~ApplicationServer();
  23. void incomingConnection(qintptr socketDescriptor) override;
  24. virtual bool startListening(unsigned short port = 0) = 0;
  25. //! ApplicationServerBus Handler
  26. int GetServerListeningPort() const override;
  27. static const char RandomListeningPortOption[];
  28. Q_SIGNALS:
  29. void newIncomingConnection(qintptr socketDescriptor);
  30. void ReadyToQuit(QObject* source);
  31. public Q_SLOTS:
  32. void QuitRequested();
  33. protected:
  34. int m_serverListeningPort = 0;
  35. bool m_isShuttingDown = false;
  36. };