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
async_web_server_cpp::WebsocketConnection::sendTextMessage
bool sendTextMessage(const std::string &content)
Definition: websocket_connection.cpp:21
async_web_server_cpp::WebsocketConnection::handler_
MessageHandler handler_
Definition: websocket_connection.hpp:49
async_web_server_cpp::WebsocketConnection::static_handle_read
static void static_handle_read(WebsocketConnectionWeakPtr weak_this, const char *begin, const char *end)
Definition: websocket_connection.cpp:57
async_web_server_cpp::WebsocketConnection::frame_parser_
WebsocketFrameParser frame_parser_
Definition: websocket_connection.hpp:53
http_connection.hpp
async_web_server_cpp::WebsocketFrame
Definition: websocket_message.hpp:27
async_web_server_cpp::WebsocketFrameBuffer
Definition: websocket_message.hpp:125
async_web_server_cpp::WebsocketConnection::frame_buffer_
WebsocketFrameBuffer frame_buffer_
Definition: websocket_connection.hpp:54
async_web_server_cpp
Definition: http_connection.hpp:14
async_web_server_cpp::WebsocketConnectionWeakPtr
boost::weak_ptr< WebsocketConnection > WebsocketConnectionWeakPtr
Definition: websocket_connection.hpp:20
async_web_server_cpp::WebsocketConnectionPtr
boost::shared_ptr< WebsocketConnection > WebsocketConnectionPtr
Definition: websocket_connection.hpp:18
websocket_message.hpp
async_web_server_cpp::WebsocketConnection::handle_read
void handle_read(const char *begin, const char *end)
Definition: websocket_connection.cpp:64
async_web_server_cpp::WebsocketConnection::frame_
WebsocketFrame frame_
Definition: websocket_connection.hpp:51
async_web_server_cpp::HttpConnectionPtr
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Definition: http_connection.hpp:17
async_web_server_cpp::WebsocketConnection::WebsocketConnection
WebsocketConnection(HttpConnectionPtr connection)
Definition: websocket_connection.cpp:11
async_web_server_cpp::WebsocketConnection::message_
WebsocketMessage message_
Definition: websocket_connection.hpp:52
async_web_server_cpp::WebsocketMessage
Definition: websocket_message.hpp:109
async_web_server_cpp::WebsocketConnection
Definition: websocket_connection.hpp:26
async_web_server_cpp::WebsocketFrameParser
Definition: websocket_message.hpp:64
async_web_server_cpp::WebsocketHttpRequestHandler
Definition: websocket_request_handler.hpp:23
async_web_server_cpp::WebsocketConnection::sendFrame
bool sendFrame(WebsocketFrame &frame)
Definition: websocket_connection.cpp:46
async_web_server_cpp::WebsocketConnection::MessageHandler
boost::function< void(const WebsocketMessage &message)> MessageHandler
Definition: websocket_connection.hpp:34
async_web_server_cpp::WebsocketConnection::set_message_handler
void set_message_handler(MessageHandler &handler)
Definition: websocket_connection.cpp:16
async_web_server_cpp::WebsocketConnection::connection_
HttpConnectionPtr connection_
Definition: websocket_connection.hpp:46
async_web_server_cpp::WebsocketConnection::sendPingMessage
bool sendPingMessage(const std::string &content="")
Definition: websocket_connection.cpp:28
async_web_server_cpp::WebsocketConnection::sendMessage
bool sendMessage(const WebsocketMessage &message)
Definition: websocket_connection.cpp:36


async_web_server_cpp
Author(s): Mitchell Wills , Russel Toris
autogenerated on Tue Mar 1 2022 23:49:06