mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
Init project
This commit is contained in:
50
tests/signal_server/signal_server.h
Normal file
50
tests/signal_server/signal_server.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _SIGNAL_SERVER_H_
|
||||
#define _SIGNAL_SERVER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
#include <websocketpp/config/asio_no_tls.hpp>
|
||||
#include <websocketpp/server.hpp>
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
typedef websocketpp::server<websocketpp::config::asio> server;
|
||||
typedef unsigned int connection_id;
|
||||
typedef std::string room_id;
|
||||
|
||||
class SignalServer {
|
||||
public:
|
||||
SignalServer();
|
||||
~SignalServer();
|
||||
|
||||
bool on_open(websocketpp::connection_hdl hdl);
|
||||
|
||||
bool on_close(websocketpp::connection_hdl hdl);
|
||||
|
||||
bool on_ping(websocketpp::connection_hdl hdl, std::string s);
|
||||
|
||||
bool on_pong(websocketpp::connection_hdl hdl, std::string s);
|
||||
|
||||
void run();
|
||||
|
||||
void on_message(websocketpp::connection_hdl hdl, server::message_ptr msg);
|
||||
|
||||
void send_msg(websocketpp::connection_hdl hdl, json message);
|
||||
|
||||
private:
|
||||
server server_;
|
||||
std::map<websocketpp::connection_hdl, connection_id,
|
||||
std::owner_less<websocketpp::connection_hdl>>
|
||||
connections_;
|
||||
std::map<room_id, connection_id> rooms_;
|
||||
unsigned int connection_id_ = 0;
|
||||
std::string transport_id_ = "000000";
|
||||
std::map<std::string, std::string> offer_sdp_map_;
|
||||
std::map<std::string, std::string> answer_sdp_map_;
|
||||
std::map<std::string, websocketpp::connection_hdl> offer_hdl_map_;
|
||||
std::map<std::string, websocketpp::connection_hdl> answer_hdl_map_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user