WebSocketServer.h
1.35 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __WEB_SOCKET_SERVER__
#define __WEB_SOCKET_SERVER__
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#include "SipServer.h"
#include <map>
#include <mutex>
typedef websocketpp::server<websocketpp::config::asio> server;
// pull out the type of messages sent by our config
typedef server::message_ptr message_ptr;
class WebSocketServer
{
public:
WebSocketServer(/* args */);
~WebSocketServer();
// Define a callback to handle incoming messages
void void on_message(websocketpp::connection_hdl hdl, message_ptr msg) ;(websocketpp::connection_hdl hdl, message_ptr msg) void on_message(websocketpp::connection_hdl hdl, message_ptr msg) ;
void on_open(websocketpp::connection_hdl hdl);
void on_close(websocketpp::connection_hdl hdl);
void on_fail(websocketpp::connection_hdl hdl);
void start();
void response_client(std::string sip_channel_id, int rtp_port, std::string net_type, int ret);
private:
int msg_parser(websocketpp::connection_hdl hdl, string msg);
int parse_invite(vector<string>& vec_msg, std::string ip);
string get_ip_from_hdl(websocketpp::connection_hdl hdl);
private:
server ws_server;
SipServer sip_server;
std::map<string, websocketpp::connection_hdl> m_channelport_hdl_map;
std::mutex m_channelport_hdl_map_mtx;
std::multimap<server::connection_ptr, tuple<std::string, std::string, int> > m_hdl_task;
std::mutex m_hdl_task_mtx;
};
#endif // __WEB_SOCKET_SERVER__