@ -1,23 +1,28 @@
|
||||
#include "SignalServer.h"
|
||||
#include "../Application.h"
|
||||
#include "../HttpSession.h"
|
||||
#include "Base/HttpSession.h"
|
||||
#include "Base/Messages.h"
|
||||
#include "Core/Logger.h"
|
||||
#include "Core/Singleton.h"
|
||||
#include "WebSocketSignalSession.h"
|
||||
#include <boost/beast/websocket/rfc6455.hpp>
|
||||
|
||||
namespace Older {
|
||||
SignalServer::SignalServer(Application &app) {
|
||||
using namespace boost::urls;
|
||||
using namespace Core;
|
||||
// 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<WebSocketSignalSession>(session.releaseSocket(), *this, id);
|
||||
ws->run(request);
|
||||
} else {
|
||||
LOG(error) << "webrtc client[" << id << "] not upgrade connection, request: " << std::endl << request;
|
||||
}
|
||||
});
|
||||
auto manager = Singleton<MessageManager>::instance();
|
||||
if (manager) {
|
||||
manager->publish<RegisterUrlHandler>("/api/v1/webrtc/signal/{id}", [this](HttpSession &session, const HttpRequest &request, const matches &matches) {
|
||||
auto id = matches.at("id");
|
||||
if (boost::beast::websocket::is_upgrade(request)) {
|
||||
auto ws = std::make_shared<WebSocketSignalSession>(session.releaseSocket(), *this, id);
|
||||
ws->run(request);
|
||||
} else {
|
||||
LOG(error) << "webrtc client[" << id << "] not upgrade connection, request: " << std::endl << request;
|
||||
}
|
||||
});
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user