forked from paullouisageneau/libdatachannel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsocketserver.cpp
36 lines (24 loc) · 950 Bytes
/
websocketserver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright (c) 2021 Paul-Louis Ageneau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#if RTC_ENABLE_WEBSOCKET
#include "websocketserver.hpp"
#include "common.hpp"
#include "impl/internals.hpp"
#include "impl/websocketserver.hpp"
namespace rtc {
WebSocketServer::WebSocketServer() : WebSocketServer(Configuration()) {}
WebSocketServer::WebSocketServer(Configuration config)
: CheshireCat<impl::WebSocketServer>(std::move(config)) {}
WebSocketServer::~WebSocketServer() { impl()->stop(); }
void WebSocketServer::stop() { impl()->stop(); }
uint16_t WebSocketServer::port() const { return impl()->tcpServer->port(); }
void WebSocketServer::onClient(std::function<void(shared_ptr<WebSocket>)> callback) {
impl()->clientCallback = callback;
}
} // namespace rtc
#endif