#include "SignalServer.h" #include "../Application.h" #include "../HttpSession.h" #include "BoostLog.h" #include "WebSocketSignalSession.h" #include SignalServer::SignalServer(Application &app) { using namespace boost::urls; // clang-format off app.insertUrl("/api/v1/webrtc/signal/{id}", [this](HttpSession &session, const Application::Request &request, const matches &matches) { auto id = matches.at("id"); if (boost::beast::websocket::is_upgrade(request)) { auto ws = std::make_shared(session.releaseSocket(), *this, id); ws->run(request); } }); // clang-format on } void SignalServer::join(const std::string &id, WebSocketSignalSession *client) { m_clients.insert({id, client}); } void SignalServer::leave(const std::string &id) { if (m_clients.contains(id)) { m_clients.erase(id); } } WebSocketSignalSession *SignalServer::client(const std::string &id) { WebSocketSignalSession *ret = nullptr; if (m_clients.contains(id)) { ret = m_clients.at(id); } return ret; }