WebSocket++
0.8.3-dev
C++ websocket client/server library
|
28 #ifndef WEBSOCKETPP_MESSAGE_BUFFER_MESSAGE_HPP
29 #define WEBSOCKETPP_MESSAGE_BUFFER_MESSAGE_HPP
31 #include <websocketpp/common/memory.hpp>
32 #include <websocketpp/frame.hpp>
37 namespace message_buffer {
83 template <
template<
class>
class con_msg_manager>
86 typedef lib::shared_ptr<message> ptr;
88 typedef con_msg_manager<message> con_msg_man_type;
89 typedef typename con_msg_man_type::ptr con_msg_man_ptr;
90 typedef typename con_msg_man_type::weak_ptr con_msg_man_weak_ptr;
101 , m_compressed(
false) {}
107 message(
const con_msg_man_ptr manager, frame::opcode::value op, size_t size = 128)
113 , m_compressed(
false)
115 m_payload.reserve(size);
157 m_compressed = value;
238 std::string
const & get_extension_data()
const {
239 return m_extension_data;
276 m_payload.reserve(len);
277 char const * pl =
static_cast<
char const *>(payload);
278 m_payload.assign(pl, pl + len);
288 m_payload.append(payload);
299 m_payload.reserve(m_payload.size()+len);
300 m_payload.append(
static_cast<
char const *>(payload),len);
317 con_msg_man_ptr shared = m_manager.lock();
320 return shared->recycle(
this);
326 con_msg_man_weak_ptr m_manager;
327 std::string m_header;
328 std::string m_extension_data;
329 std::string m_payload;
330 frame::opcode::value m_opcode;
std::string const & get_payload() const
Get a reference to the payload string.
void set_terminal(bool value)
Set the terminal flag.
void set_fin(bool value)
Set the fin bit.
message(const con_msg_man_ptr manager)
Construct an empty message.
std::string & get_raw_payload()
Get a non-const reference to the payload string.
bool get_prepared() const
Return whether or not the message has been prepared for sending.
static std::vector< int > const versions_supported(helper, helper+4)
Container that stores the list of protocol versions supported.
void set_opcode(frame::opcode::value op)
Set the opcode.
void append_payload(std::string const &payload)
Append payload data.
message(const con_msg_man_ptr manager, frame::opcode::value op, size_t size=128)
Construct a message and fill in some values.
void set_compressed(bool value)
Set or clear the compression flag.
void set_header(std::string const &header)
Set prepared frame header.
bool get_compressed() const
Return whether or not the message is flagged as compressed.
bool get_terminal() const
Get whether or not the message is terminal.
void append_payload(void const *payload, size_t len)
Append payload data.
std::string const & get_header() const
Return the prepared frame header.
void set_prepared(bool value)
Set or clear the flag that indicates that the message has been prepared.
bool get_fin() const
Read the fin bit.
frame::opcode::value get_opcode() const
Return the message opcode.
void set_payload(void const *payload, size_t len)
Set payload data.
void set_payload(std::string const &payload)
Set payload data.
bool recycle()
Recycle the message.