websocketserver.cpp 950 B

123456789101112131415161718192021222324252627282930313233343536
  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. #if RTC_ENABLE_WEBSOCKET
  9. #include "websocketserver.hpp"
  10. #include "common.hpp"
  11. #include "impl/internals.hpp"
  12. #include "impl/websocketserver.hpp"
  13. namespace rtc {
  14. WebSocketServer::WebSocketServer() : WebSocketServer(Configuration()) {}
  15. WebSocketServer::WebSocketServer(Configuration config)
  16. : CheshireCat<impl::WebSocketServer>(std::move(config)) {}
  17. WebSocketServer::~WebSocketServer() { impl()->stop(); }
  18. void WebSocketServer::stop() { impl()->stop(); }
  19. uint16_t WebSocketServer::port() const { return impl()->tcpServer->port(); }
  20. void WebSocketServer::onClient(std::function<void(shared_ptr<WebSocket>)> callback) {
  21. impl()->clientCallback = callback;
  22. }
  23. } // namespace rtc
  24. #endif