28#ifndef WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP
29#define WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP
31#include <websocketpp/common/memory.hpp>
36namespace message_buffer {
84void message_deleter(T* msg) {
86 if (!msg->recycle()) {
100template <
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;
159template <
typename message>
160class 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);
194template <
typename con_msg_manager>
195class endpoint_msg_manager {
197 typedef typename con_msg_manager::ptr con_msg_man_ptr;
204 return lib::make_shared<con_msg_manager>();
message_ptr get_message(size_t size) const
Get a message buffer with specified size.
bool recycle(message *msg)
Recycle a message.
con_msg_man_ptr get_manager() const
Get a pointer to a connection message manager.
Represents a buffer for a single WebSocket message.
bool recycle()
Recycle the message.
std::string const & get_header() const
Return the prepared frame header.
frame::opcode::value get_opcode() const
Return the message opcode.
message(const con_msg_man_ptr manager)
Construct an empty message.
std::string const & get_payload() const
Get a reference to the payload string.
Namespace for the WebSocket++ project.