2
0

websocketserver.hpp 943 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) 2021 Paul-Louis Ageneau
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. #ifndef RTC_WEBSOCKETSERVER_H
  9. #define RTC_WEBSOCKETSERVER_H
  10. #if RTC_ENABLE_WEBSOCKET
  11. #include "common.hpp"
  12. #include "configuration.hpp"
  13. #include "websocket.hpp"
  14. namespace rtc {
  15. namespace impl {
  16. struct WebSocketServer;
  17. }
  18. class RTC_CPP_EXPORT WebSocketServer final : private CheshireCat<impl::WebSocketServer> {
  19. public:
  20. using Configuration = WebSocketServerConfiguration;
  21. WebSocketServer();
  22. WebSocketServer(Configuration config);
  23. ~WebSocketServer();
  24. void stop();
  25. uint16_t port() const;
  26. void onClient(std::function<void(shared_ptr<WebSocket>)> callback);
  27. private:
  28. using CheshireCat<impl::WebSocketServer>::impl;
  29. };
  30. } // namespace rtc
  31. #endif
  32. #endif // RTC_WEBSOCKET_H