Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
websocketpp::message_buffer::message< con_msg_manager > Class Template Reference

Represents a buffer for a single WebSocket message. More...

#include <message.hpp>

Public Types

typedef lib::shared_ptr< messageptr
 
typedef con_msg_manager< messagecon_msg_man_type
 
typedef con_msg_man_type::ptr con_msg_man_ptr
 
typedef con_msg_man_type::weak_ptr con_msg_man_weak_ptr
 
typedef con_msg_manager::weak_ptr con_msg_man_ptr
 

Public Member Functions

 message (const con_msg_man_ptr manager)
 Construct an empty message.
 
 message (const con_msg_man_ptr manager, frame::opcode::value op, size_t size=128)
 Construct a message and fill in some values.
 
bool get_prepared () const
 Return whether or not the message has been prepared for sending.
 
void set_prepared (bool value)
 Set or clear the flag that indicates that the message has been prepared.
 
bool get_compressed () const
 Return whether or not the message is flagged as compressed.
 
void set_compressed (bool value)
 Set or clear the compression flag.
 
bool get_terminal () const
 Get whether or not the message is terminal.
 
void set_terminal (bool value)
 Set the terminal flag.
 
bool get_fin () const
 Read the fin bit.
 
void set_fin (bool value)
 Set the fin bit.
 
frame::opcode::value get_opcode () const
 Return the message opcode.
 
void set_opcode (frame::opcode::value op)
 Set the opcode.
 
std::string const & get_header () const
 Return the prepared frame header.
 
void set_header (std::string const &header)
 Set prepared frame header.
 
std::string const & get_extension_data () const
 
std::string const & get_payload () const
 Get a reference to the payload string.
 
std::string & get_raw_payload ()
 Get a non-const reference to the payload string.
 
void set_payload (std::string const &payload)
 Set payload data.
 
void set_payload (void const *payload, size_t len)
 Set payload data.
 
void append_payload (std::string const &payload)
 Append payload data.
 
void append_payload (void const *payload, size_t len)
 Append payload data.
 
bool recycle ()
 Recycle the message.
 
 message (con_msg_man_ptr manager, size_t size=128)
 
frame::opcode::value get_opcode () const
 
const std::string & get_header () const
 
const std::string & get_extension_data () const
 
const std::string & get_payload () const
 
bool recycle ()
 Recycle the message.
 

Detailed Description

template<typename con_msg_manager>
class websocketpp::message_buffer::message< con_msg_manager >

Definition at line 101 of file pool.hpp.

Member Typedef Documentation

◆ con_msg_man_ptr [1/2]

template<typename con_msg_manager >
con_msg_man_type::ptr websocketpp::message_buffer::message< con_msg_manager >::con_msg_man_ptr

Definition at line 89 of file message.hpp.

◆ con_msg_man_ptr [2/2]

template<typename con_msg_manager >
con_msg_manager::weak_ptr websocketpp::message_buffer::message< con_msg_manager >::con_msg_man_ptr

Definition at line 105 of file pool.hpp.

◆ con_msg_man_type

template<typename con_msg_manager >
con_msg_manager<message> websocketpp::message_buffer::message< con_msg_manager >::con_msg_man_type

Definition at line 88 of file message.hpp.

◆ con_msg_man_weak_ptr

template<typename con_msg_manager >
con_msg_man_type::weak_ptr websocketpp::message_buffer::message< con_msg_manager >::con_msg_man_weak_ptr

Definition at line 90 of file message.hpp.

◆ ptr

template<typename con_msg_manager >
typedef lib::shared_ptr< message > websocketpp::message_buffer::message< con_msg_manager >::ptr

Definition at line 86 of file message.hpp.

Constructor & Destructor Documentation

◆ message() [1/3]

template<typename con_msg_manager >
websocketpp::message_buffer::message< con_msg_manager >::message ( const con_msg_man_ptr manager)
inline

Construct an empty message

Definition at line 96 of file message.hpp.

97 : m_manager(manager)
98 , m_prepared(false)
99 , m_fin(true)
100 , m_terminal(false)
101 , m_compressed(false) {}

◆ message() [2/3]

template<typename con_msg_manager >
websocketpp::message_buffer::message< con_msg_manager >::message ( const con_msg_man_ptr manager,
frame::opcode::value op,
size_t size = 128 )
inline

Definition at line 107 of file message.hpp.

108 : m_manager(manager)
109 , m_opcode(op)
110 , m_prepared(false)
111 , m_fin(true)
112 , m_terminal(false)
113 , m_compressed(false)
114 {
115 m_payload.reserve(size);
116 }

◆ message() [3/3]

template<typename con_msg_manager >
websocketpp::message_buffer::message< con_msg_manager >::message ( con_msg_man_ptr manager,
size_t size = 128 )
inline

Definition at line 107 of file pool.hpp.

108 : m_manager(manager)
109 , m_payload(size) {}

Member Function Documentation

◆ append_payload() [1/2]

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::append_payload ( std::string const & payload)
inline

Append data to the message buffer's payload.

Parameters
payloadA string containing the data array to append.

Definition at line 287 of file message.hpp.

287 {
288 m_payload.append(payload);
289 }

◆ append_payload() [2/2]

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::append_payload ( void const * payload,
size_t len )
inline

Append data to the message buffer's payload.

Parameters
payloadA pointer to a data array to append
lenThe length of payload in bytes

Definition at line 298 of file message.hpp.

298 {
299 m_payload.reserve(m_payload.size()+len);
300 m_payload.append(static_cast<char const *>(payload),len);
301 }
size_t len

◆ get_compressed()

template<typename con_msg_manager >
bool websocketpp::message_buffer::message< con_msg_manager >::get_compressed ( ) const
inline
Returns
whether or not the message is/should be compressed

Definition at line 143 of file message.hpp.

143 {
144 return m_compressed;
145 }

◆ get_extension_data() [1/2]

template<typename con_msg_manager >
std::string const & websocketpp::message_buffer::message< con_msg_manager >::get_extension_data ( ) const
inline

Definition at line 238 of file message.hpp.

238 {
239 return m_extension_data;
240 }

◆ get_extension_data() [2/2]

template<typename con_msg_manager >
const std::string & websocketpp::message_buffer::message< con_msg_manager >::get_extension_data ( ) const
inline

Definition at line 117 of file pool.hpp.

117 {
118 return m_extension_data;
119 }

◆ get_fin()

template<typename con_msg_manager >
bool websocketpp::message_buffer::message< con_msg_manager >::get_fin ( ) const
inline

A message with the fin bit set will be sent as the last message of its sequence. A message with the fin bit cleared will require subsequent frames of opcode continuation until one of them has the fin bit set.

The remote end likely will not deliver any bytes until the frame with the fin bit set has been received.

Returns
Whether or not the fin bit is set

Definition at line 195 of file message.hpp.

195 {
196 return m_fin;
197 }

◆ get_header() [1/2]

template<typename con_msg_manager >
std::string const & websocketpp::message_buffer::message< con_msg_manager >::get_header ( ) const
inline

This value is typically set by a websocket protocol processor and shouldn't be tampered with.

Definition at line 224 of file message.hpp.

224 {
225 return m_header;
226 }

◆ get_header() [2/2]

template<typename con_msg_manager >
const std::string & websocketpp::message_buffer::message< con_msg_manager >::get_header ( ) const
inline

Definition at line 114 of file pool.hpp.

114 {
115 return m_header;
116 }

◆ get_opcode() [1/2]

template<typename con_msg_manager >
frame::opcode::value websocketpp::message_buffer::message< con_msg_manager >::get_opcode ( ) const
inline

Definition at line 210 of file message.hpp.

210 {
211 return m_opcode;
212 }

◆ get_opcode() [2/2]

template<typename con_msg_manager >
frame::opcode::value websocketpp::message_buffer::message< con_msg_manager >::get_opcode ( ) const
inline

Definition at line 111 of file pool.hpp.

111 {
112 return m_opcode;
113 }

◆ get_payload() [1/2]

template<typename con_msg_manager >
std::string const & websocketpp::message_buffer::message< con_msg_manager >::get_payload ( ) const
inline
Returns
A const reference to the message's payload string

Definition at line 246 of file message.hpp.

246 {
247 return m_payload;
248 }

◆ get_payload() [2/2]

template<typename con_msg_manager >
const std::string & websocketpp::message_buffer::message< con_msg_manager >::get_payload ( ) const
inline

Definition at line 120 of file pool.hpp.

120 {
121 return m_payload;
122 }

◆ get_prepared()

template<typename con_msg_manager >
bool websocketpp::message_buffer::message< con_msg_manager >::get_prepared ( ) const
inline

The prepared flag indicates that the message has been prepared by a websocket protocol processor and is ready to be written to the wire.

Returns
whether or not the message has been prepared for sending

Definition at line 125 of file message.hpp.

125 {
126 return m_prepared;
127 }

◆ get_raw_payload()

template<typename con_msg_manager >
std::string & websocketpp::message_buffer::message< con_msg_manager >::get_raw_payload ( )
inline
Returns
A reference to the message's payload string

Definition at line 254 of file message.hpp.

254 {
255 return m_payload;
256 }

◆ get_terminal()

template<typename con_msg_manager >
bool websocketpp::message_buffer::message< con_msg_manager >::get_terminal ( ) const
inline

Messages can be flagged as terminal, which results in the connection being close after they are written rather than the implementation going on to the next message in the queue. This is typically used internally for close messages only.

Returns
Whether or not this message is marked terminal

Definition at line 169 of file message.hpp.

169 {
170 return m_terminal;
171 }

◆ recycle() [1/2]

template<typename con_msg_manager >
bool websocketpp::message_buffer::message< con_msg_manager >::recycle ( )
inline

A request to recycle this message was received. Forward that request to the connection message manager for processing. Errors and exceptions from the manager's recycle member function should be passed back up the call chain. The caller to message::recycle will deal with them.

Recycle must only be called by the message shared_ptr's destructor. Once recycled successfully, ownership of the memory has been passed to another system and must not be accessed again.

Returns
true if the message was successfully recycled, false otherwise.

Definition at line 316 of file message.hpp.

316 {
317 con_msg_man_ptr shared = m_manager.lock();
318
319 if (shared) {
320 return shared->recycle(this);
321 } else {
322 return false;
323 }
324 }
con_msg_man_type::ptr con_msg_man_ptr
Definition message.hpp:89

◆ recycle() [2/2]

template<typename con_msg_manager >
bool websocketpp::message_buffer::message< con_msg_manager >::recycle ( )
inline

A request to recycle this message was received. Forward that request to the connection message manager for processing. Errors and exceptions from the manager's recycle member function should be passed back up the call chain. The caller to message::recycle will deal with them.

Recycle must only be called by the message shared_ptr's destructor. Once recycled successfully, ownership of the memory has been passed to another system and must not be accessed again.

Returns
true if the message was successfully recycled, false otherwise.

Definition at line 137 of file pool.hpp.

137 {
138 typename con_msg_manager::ptr shared = m_manager.lock();
139
140 if (shared) {
141 return shared->(recycle(this));
142 } else {
143 return false;
144 }
145 }

◆ set_compressed()

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_compressed ( bool value)
inline

Setting the compression flag indicates that the data in this message would benefit from compression. If both endpoints negotiate a compression extension WebSocket++ will attempt to compress messages with this flag. Setting this flag does not guarantee that the message will be compressed.

Parameters
valueThe value to set the compressed flag to

Definition at line 156 of file message.hpp.

156 {
157 m_compressed = value;
158 }
#define value
Definition pkcs11.h:157

◆ set_fin()

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_fin ( bool value)
inline
See also
get_fin for a more detailed explaination of the fin bit
Parameters
valueThe value to set the fin bit to.

Definition at line 205 of file message.hpp.

205 {
206 m_fin = value;
207 }

◆ set_header()

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_header ( std::string const & header)
inline

Under normal circumstances this should not be called by end users

Parameters
headerA string to set the header to.

Definition at line 234 of file message.hpp.

234 {
235 m_header = header;
236 }

◆ set_opcode()

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_opcode ( frame::opcode::value op)
inline

Definition at line 215 of file message.hpp.

215 {
216 m_opcode = op;
217 }

◆ set_payload() [1/2]

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_payload ( std::string const & payload)
inline

Set the message buffer's payload to the given value.

Parameters
payloadA string to set the payload to.

Definition at line 264 of file message.hpp.

264 {
265 m_payload = payload;
266 }

◆ set_payload() [2/2]

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_payload ( void const * payload,
size_t len )
inline

Set the message buffer's payload to the given value.

Parameters
payloadA pointer to a data array to set to.
lenThe length of new payload in bytes.

Definition at line 275 of file message.hpp.

275 {
276 m_payload.reserve(len);
277 char const * pl = static_cast<char const *>(payload);
278 m_payload.assign(pl, pl + len);
279 }

◆ set_prepared()

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_prepared ( bool value)
inline

This flag should not be set by end user code without a very good reason.

Parameters
valueThe value to set the prepared flag to

Definition at line 135 of file message.hpp.

135 {
136 m_prepared = value;
137 }

◆ set_terminal()

template<typename con_msg_manager >
void websocketpp::message_buffer::message< con_msg_manager >::set_terminal ( bool value)
inline

This flag should not be set by end user code without a very good reason.

See also
get_terminal()
Parameters
valueThe value to set the terminal flag to.

Definition at line 181 of file message.hpp.

181 {
182 m_terminal = value;
183 }

The documentation for this class was generated from the following files: