Blame view

sip/WebSocketServer.h 1.23 KB
4efb6240   Hu Chunming   call release 自动重新...
1
2
3
  #ifndef __WEB_SOCKET_SERVER__
  #define __WEB_SOCKET_SERVER__
  
c887a0f0   Hu Chunming   提交初成版代码
4
5
6
7
  #include <websocketpp/config/asio_no_tls.hpp>
  #include <websocketpp/server.hpp>
  
  #include "SipServer.h"
4efb6240   Hu Chunming   call release 自动重新...
8
9
  #include <map>
  #include <mutex>
c887a0f0   Hu Chunming   提交初成版代码
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
  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();
  
4efb6240   Hu Chunming   call release 自动重新...
32
33
      void response_client(std::string sip_channel_id, int rtp_port, std::string net_type, int ret);
  
c887a0f0   Hu Chunming   提交初成版代码
34
35
36
37
38
39
40
41
42
  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;
4efb6240   Hu Chunming   call release 自动重新...
43
44
45
46
47
48
  
      std::map<string, websocketpp::connection_hdl> m_channelport_hdl_map;
      std::mutex m_channelport_hdl_map_mtx;
  };
  
  #endif      // __WEB_SOCKET_SERVER__