websocket_connection.hpp
Go to the documentation of this file.
1 #ifndef CPP_WEB_SERVER_WEBSOCKET_CONNECTION_HPP
2 #define CPP_WEB_SERVER_WEBSOCKET_CONNECTION_HPP
3 
6 
7 #include <boost/asio.hpp>
8 #include <boost/enable_shared_from_this.hpp>
9 #include <boost/noncopyable.hpp>
10 #include <boost/shared_ptr.hpp>
11 #include <boost/thread/mutex.hpp>
12 
13 namespace async_web_server_cpp
14 {
15 
16 class WebsocketHttpRequestHandler;
17 
19 typedef boost::shared_ptr<WebsocketConnection> WebsocketConnectionPtr;
20 typedef boost::weak_ptr<WebsocketConnection> WebsocketConnectionWeakPtr;
21 
27  : public boost::enable_shared_from_this<WebsocketConnection>,
28  private boost::noncopyable
29 {
30 public:
31  explicit WebsocketConnection(HttpConnectionPtr connection);
32 
33  typedef boost::function<void(const WebsocketMessage& message)>
35 
36  bool sendTextMessage(const std::string& content);
37  bool sendPingMessage(const std::string& content = "");
38 
39  bool sendMessage(const WebsocketMessage& message);
40  bool sendFrame(WebsocketFrame& frame);
41 
42 private:
43  static void static_handle_read(WebsocketConnectionWeakPtr weak_this,
44  const char* begin, const char* end);
45  void handle_read(const char* begin, const char* end);
47 
48  void set_message_handler(MessageHandler& handler);
50 
55 
57 };
58 
59 } // namespace async_web_server_cpp
60 
61 #endif
boost::function< void(const WebsocketMessage &message)> MessageHandler
bool sendPingMessage(const std::string &content="")
boost::shared_ptr< WebsocketConnection > WebsocketConnectionPtr
boost::shared_ptr< HttpConnection > HttpConnectionPtr
void handle_read(const char *begin, const char *end)
static void static_handle_read(WebsocketConnectionWeakPtr weak_this, const char *begin, const char *end)
boost::weak_ptr< WebsocketConnection > WebsocketConnectionWeakPtr
bool sendMessage(const WebsocketMessage &message)
void set_message_handler(MessageHandler &handler)
WebsocketConnection(HttpConnectionPtr connection)
bool sendTextMessage(const std::string &content)


async_web_server_cpp
Author(s): Mitchell Wills , Russel Toris
autogenerated on Mon Feb 28 2022 21:54:08