28 #ifndef WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP
29 #define WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP
31 #include <websocketpp/common/memory.hpp>
36 namespace message_buffer {
84 void message_deleter(T* msg) {
86 if (!msg->recycle()) {
100 template <
typename con_msg_manager>
103 typedef lib::shared_ptr<message> ptr;
105 typedef typename con_msg_manager::weak_ptr con_msg_man_ptr;
107 message(con_msg_man_ptr manager,
size_t size = 128)
117 const std::string& get_extension_data()
const {
118 return m_extension_data;
138 typename con_msg_manager::ptr shared = m_manager.lock();
141 return shared->(recycle(
this));
147 con_msg_man_ptr m_manager;
149 frame::opcode::value m_opcode;
150 std::string m_header;
151 std::string m_extension_data;
152 std::string m_payload;
159 template <
typename message>
160 class con_msg_manager {
162 typedef lib::shared_ptr<con_msg_manager> ptr;
163 typedef lib::weak_ptr<con_msg_manager> weak_ptr;
165 typedef typename message::ptr message_ptr;
174 return lib::make_shared<message>(size);
194 template <
typename con_msg_manager>
195 class endpoint_msg_manager {
197 typedef typename con_msg_manager::ptr con_msg_man_ptr;
204 return lib::make_shared<con_msg_manager>();
229 #endif // WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP
con_msg_man_ptr get_manager() const
Get a pointer to a connection message manager.
message(const con_msg_man_ptr manager)
Construct an empty message.
std::string const & get_payload() const
Get a reference to the payload string.
frame::opcode::value get_opcode() const
Return the message opcode.
Namespace for the WebSocket++ project.
Represents a buffer for a single WebSocket message.
message_ptr get_message(size_t size) const
Get a message buffer with specified size.
std::string const & get_header() const
Return the prepared frame header.
bool recycle(message *msg)
Recycle a message.
bool recycle()
Recycle the message.