Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
websocketpp::endpoint< connection, config > Class Template Reference

Creates and manages connections associated with a WebSocket endpoint. More...

#include <endpoint.hpp>

Inheritance diagram for websocketpp::endpoint< connection, config >:
Collaboration diagram for websocketpp::endpoint< connection, config >:

Public Types

typedef endpoint< connection, configtype
 
typedef config::transport_type transport_type
 Type of the transport component of this endpoint.
 
typedef config::concurrency_type concurrency_type
 Type of the concurrency component of this endpoint.
 
typedef connection connection_type
 Type of the connections that this endpoint creates.
 
typedef connection_type::ptr connection_ptr
 Shared pointer to connection_type.
 
typedef connection_type::weak_ptr connection_weak_ptr
 Weak pointer to connection type.
 
typedef transport_type::transport_con_type transport_con_type
 
typedef transport_con_type::ptr transport_con_ptr
 
typedef connection_type::message_handler message_handler
 Type of message_handler.
 
typedef connection_type::message_ptr message_ptr
 Type of message pointers that this endpoint uses.
 
typedef config::elog_type elog_type
 Type of error logger.
 
typedef config::alog_type alog_type
 Type of access logger.
 
typedef concurrency_type::scoped_lock_type scoped_lock_type
 Type of our concurrency policy's scoped lock object.
 
typedef concurrency_type::mutex_type mutex_type
 Type of our concurrency policy's mutex object.
 
typedef config::rng_type rng_type
 Type of RNG.
 
typedef connection_type::termination_handler termination_handler
 

Public Member Functions

 endpoint (bool p_is_server)
 
 ~endpoint ()
 Destructor.
 
std::string get_user_agent () const
 Returns the user agent string that this endpoint will use.
 
void set_user_agent (std::string const &ua)
 Sets the user agent string that this endpoint will use.
 
bool is_server () const
 Returns whether or not this endpoint is a server.
 
void set_access_channels (log::level channels)
 Set Access logging channel.
 
void clear_access_channels (log::level channels)
 Clear Access logging channels.
 
void set_error_channels (log::level channels)
 Set Error logging channel.
 
void clear_error_channels (log::level channels)
 Clear Error logging channels.
 
alog_typeget_alog ()
 Get reference to access logger.
 
elog_typeget_elog ()
 Get reference to error logger.
 
void set_open_handler (open_handler h)
 
void set_close_handler (close_handler h)
 
void set_fail_handler (fail_handler h)
 
void set_ping_handler (ping_handler h)
 
void set_pong_handler (pong_handler h)
 
void set_pong_timeout_handler (pong_timeout_handler h)
 
void set_interrupt_handler (interrupt_handler h)
 
void set_http_handler (http_handler h)
 
void set_validate_handler (validate_handler h)
 
void set_message_handler (message_handler h)
 
void set_open_handshake_timeout (long dur)
 Set open handshake timeout.
 
void set_close_handshake_timeout (long dur)
 Set close handshake timeout.
 
void set_pong_timeout (long dur)
 Set pong timeout.
 
size_t get_max_message_size () const
 Get default maximum message size.
 
void set_max_message_size (size_t new_value)
 Set default maximum message size.
 
size_t get_max_http_body_size () const
 Get maximum HTTP message body size.
 
void set_max_http_body_size (size_t new_value)
 Set maximum HTTP message body size.
 
void interrupt (connection_hdl hdl, lib::error_code &ec)
 
void interrupt (connection_hdl hdl)
 
void pause_reading (connection_hdl hdl, lib::error_code &ec)
 Pause reading of new data (exception free)
 
void pause_reading (connection_hdl hdl)
 Pause reading of new data.
 
void resume_reading (connection_hdl hdl, lib::error_code &ec)
 Resume reading of new data (exception free)
 
void resume_reading (connection_hdl hdl)
 Resume reading of new data.
 
void send_http_response (connection_hdl hdl, lib::error_code &ec)
 Send deferred HTTP Response.
 
void send_http_response (connection_hdl hdl)
 Send deferred HTTP Response (exception free)
 
void send (connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
 Create a message and add it to the outgoing send queue (exception free)
 
void send (connection_hdl hdl, std::string const &payload, frame::opcode::value op)
 Create a message and add it to the outgoing send queue.
 
void send (connection_hdl hdl, void const *payload, size_t len, frame::opcode::value op, lib::error_code &ec)
 
void send (connection_hdl hdl, void const *payload, size_t len, frame::opcode::value op)
 
void send (connection_hdl hdl, message_ptr msg, lib::error_code &ec)
 
void send (connection_hdl hdl, message_ptr msg)
 
void close (connection_hdl hdl, close::status::value const code, std::string const &reason, lib::error_code &ec)
 
void close (connection_hdl hdl, close::status::value const code, std::string const &reason)
 
void ping (connection_hdl hdl, std::string const &payload, lib::error_code &ec)
 Send a ping to a specific connection.
 
void ping (connection_hdl hdl, std::string const &payload)
 Send a ping to a specific connection.
 
void pong (connection_hdl hdl, std::string const &payload, lib::error_code &ec)
 Send a pong to a specific connection.
 
void pong (connection_hdl hdl, std::string const &payload)
 Send a pong to a specific connection.
 
connection_ptr get_con_from_hdl (connection_hdl hdl, lib::error_code &ec)
 Retrieves a connection_ptr from a connection_hdl (exception free)
 
connection_ptr get_con_from_hdl (connection_hdl hdl)
 Retrieves a connection_ptr from a connection_hdl (exception version)
 

Protected Member Functions

connection_ptr create_connection ()
 

Protected Attributes

alog_type m_alog
 
elog_type m_elog
 

Detailed Description

template<typename connection, typename config>
class websocketpp::endpoint< connection, config >

Definition at line 42 of file endpoint.hpp.

Member Typedef Documentation

◆ alog_type

template<typename connection , typename config >
config::alog_type websocketpp::endpoint< connection, config >::alog_type

Definition at line 75 of file endpoint.hpp.

◆ concurrency_type

template<typename connection , typename config >
config::concurrency_type websocketpp::endpoint< connection, config >::concurrency_type

Definition at line 51 of file endpoint.hpp.

◆ connection_ptr

Definition at line 56 of file endpoint.hpp.

◆ connection_type

template<typename connection , typename config >
connection websocketpp::endpoint< connection, config >::connection_type

Definition at line 54 of file endpoint.hpp.

◆ connection_weak_ptr

template<typename connection , typename config >
connection_type::weak_ptr websocketpp::endpoint< connection, config >::connection_weak_ptr

Definition at line 58 of file endpoint.hpp.

◆ elog_type

template<typename connection , typename config >
config::elog_type websocketpp::endpoint< connection, config >::elog_type

Definition at line 73 of file endpoint.hpp.

◆ message_handler

template<typename connection , typename config >
connection_type::message_handler websocketpp::endpoint< connection, config >::message_handler

Definition at line 68 of file endpoint.hpp.

◆ message_ptr

Definition at line 70 of file endpoint.hpp.

◆ mutex_type

template<typename connection , typename config >
concurrency_type::mutex_type websocketpp::endpoint< connection, config >::mutex_type

Definition at line 80 of file endpoint.hpp.

◆ rng_type

template<typename connection , typename config >
config::rng_type websocketpp::endpoint< connection, config >::rng_type

Definition at line 83 of file endpoint.hpp.

◆ scoped_lock_type

template<typename connection , typename config >
concurrency_type::scoped_lock_type websocketpp::endpoint< connection, config >::scoped_lock_type

Definition at line 78 of file endpoint.hpp.

◆ termination_handler

template<typename connection , typename config >
connection_type::termination_handler websocketpp::endpoint< connection, config >::termination_handler

Definition at line 86 of file endpoint.hpp.

◆ transport_con_ptr

template<typename connection , typename config >
transport_con_type::ptr websocketpp::endpoint< connection, config >::transport_con_ptr

Type of a shared pointer to the transport component of the connections that this endpoint creates.

Definition at line 65 of file endpoint.hpp.

◆ transport_con_type

template<typename connection , typename config >
transport_type::transport_con_type websocketpp::endpoint< connection, config >::transport_con_type

Type of the transport component of the connections that this endpoint creates

Definition at line 62 of file endpoint.hpp.

◆ transport_type

template<typename connection , typename config >
config::transport_type websocketpp::endpoint< connection, config >::transport_type

Definition at line 49 of file endpoint.hpp.

◆ type

Definition at line 46 of file endpoint.hpp.

Constructor & Destructor Documentation

◆ endpoint()

template<typename connection , typename config >
websocketpp::endpoint< connection, config >::endpoint ( bool p_is_server)
inlineexplicit

Definition at line 91 of file endpoint.hpp.

92 : m_alog(config::alog_level, log::channel_type_hint::access)
93 , m_elog(config::elog_level, log::channel_type_hint::error)
94 , m_user_agent(::websocketpp::user_agent)
95 , m_open_handshake_timeout_dur(config::timeout_open_handshake)
96 , m_close_handshake_timeout_dur(config::timeout_close_handshake)
97 , m_pong_timeout_dur(config::timeout_pong)
98 , m_max_message_size(config::max_message_size)
99 , m_max_http_body_size(config::max_http_body_size)
100 , m_is_server(p_is_server)
101 {
102 m_alog.set_channels(config::alog_level);
103 m_elog.set_channels(config::elog_level);
104
105 m_alog.write(log::alevel::devel, "endpoint constructor");
106
107 transport_type::init_logging(&m_alog, &m_elog);
108 }
static level const devel
Development messages (warning: very chatty)
Definition levels.hpp:141
static value const access
Access log.
Definition levels.hpp:53
static value const error
Error log.
Definition levels.hpp:55

◆ ~endpoint()

template<typename connection , typename config >
websocketpp::endpoint< connection, config >::~endpoint ( )
inline

Definition at line 91 of file endpoint.hpp.

112{}

Member Function Documentation

◆ clear_access_channels()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::clear_access_channels ( log::level channels)
inline

Clear the access logger's channel value. The value is a number whose interpretation depends on the logging policy in use.

Parameters
channelsThe channel value(s) to clear

Definition at line 231 of file endpoint.hpp.

231 {
232 m_alog.clear_channels(channels);
233 }
Here is the caller graph for this function:

◆ clear_error_channels()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::clear_error_channels ( log::level channels)
inline

Clear the error logger's channel value. The value is a number whose interpretation depends on the logging policy in use.

Parameters
channelsThe channel value(s) to clear

Definition at line 253 of file endpoint.hpp.

253 {
254 m_elog.clear_channels(channels);
255 }
Here is the caller graph for this function:

◆ close() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::close ( connection_hdl hdl,
close::status::value const code,
std::string const & reason )

Definition at line 225 of file endpoint_impl.hpp.

227{
228 lib::error_code ec;
229 close(hdl,code,reason,ec);
230 if (ec) { throw exception(ec); }
231}
void close(connection_hdl hdl, close::status::value const code, std::string const &reason, lib::error_code &ec)

◆ close() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::close ( connection_hdl hdl,
close::status::value const code,
std::string const & reason,
lib::error_code & ec )

Definition at line 215 of file endpoint_impl.hpp.

218{
219 connection_ptr con = get_con_from_hdl(hdl,ec);
220 if (ec) {return;}
221 con->close(code,reason,ec);
222}
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
Definition endpoint.hpp:643
client::connection_ptr connection_ptr
Here is the caller graph for this function:

◆ create_connection()

template<typename connection , typename config >
endpoint< connection, config >::connection_ptr websocketpp::endpoint< connection, config >::create_connection ( )
protected

Definition at line 37 of file endpoint_impl.hpp.

37 {
38 m_alog.write(log::alevel::devel,"create_connection");
39 //scoped_lock_type lock(m_state_lock);
40
41 /*if (m_state == STOPPING || m_state == STOPPED) {
42 return connection_ptr();
43 }*/
44
45 //scoped_lock_type guard(m_mutex);
46 // Create a connection on the heap and manage it using a shared pointer
47 connection_ptr con = lib::make_shared<connection_type>(m_is_server,
48 m_user_agent, lib::ref(m_alog), lib::ref(m_elog), lib::ref(m_rng));
49
51
52 // Create a weak pointer on the heap using that shared_ptr.
53 // Cast that weak pointer to void* and manage it using another shared_ptr
54 // connection_hdl hdl(reinterpret_cast<void*>(new connection_weak_ptr(con)));
55
56 con->set_handle(w);
57
58 // Copy default handlers from the endpoint
59 con->set_open_handler(m_open_handler);
60 con->set_close_handler(m_close_handler);
61 con->set_fail_handler(m_fail_handler);
62 con->set_ping_handler(m_ping_handler);
63 con->set_pong_handler(m_pong_handler);
64 con->set_pong_timeout_handler(m_pong_timeout_handler);
65 con->set_interrupt_handler(m_interrupt_handler);
66 con->set_http_handler(m_http_handler);
67 con->set_validate_handler(m_validate_handler);
68 con->set_message_handler(m_message_handler);
69
70 if (m_open_handshake_timeout_dur != config::timeout_open_handshake) {
71 con->set_open_handshake_timeout(m_open_handshake_timeout_dur);
72 }
73 if (m_close_handshake_timeout_dur != config::timeout_close_handshake) {
74 con->set_close_handshake_timeout(m_close_handshake_timeout_dur);
75 }
76 if (m_pong_timeout_dur != config::timeout_pong) {
77 con->set_pong_timeout(m_pong_timeout_dur);
78 }
79 if (m_max_message_size != config::max_message_size) {
80 con->set_max_message_size(m_max_message_size);
81 }
82 con->set_max_http_body_size(m_max_http_body_size);
83
84 lib::error_code ec;
85
86 ec = transport_type::init(con);
87 if (ec) {
88 m_elog.write(log::elevel::fatal,ec.message());
89 return connection_ptr();
90 }
91
92 return con;
93}
connection_type::weak_ptr connection_weak_ptr
Weak pointer to connection type.
Definition endpoint.hpp:58
connection_type::ptr connection_ptr
Shared pointer to connection_type.
Definition endpoint.hpp:56
static level const fatal
Definition levels.hpp:78
Here is the caller graph for this function:

◆ get_alog()

template<typename connection , typename config >
alog_type & websocketpp::endpoint< connection, config >::get_alog ( )
inline
Returns
A reference to the access logger

Definition at line 261 of file endpoint.hpp.

261 {
262 return m_alog;
263 }
Here is the caller graph for this function:

◆ get_con_from_hdl() [1/2]

template<typename connection , typename config >
connection_ptr websocketpp::endpoint< connection, config >::get_con_from_hdl ( connection_hdl hdl)
inline

Definition at line 653 of file endpoint.hpp.

653 {
654 lib::error_code ec;
655 connection_ptr con = this->get_con_from_hdl(hdl,ec);
656 if (ec) {
657 throw exception(ec);
658 }
659 return con;
660 }
Here is the call graph for this function:

◆ get_con_from_hdl() [2/2]

template<typename connection , typename config >
connection_ptr websocketpp::endpoint< connection, config >::get_con_from_hdl ( connection_hdl hdl,
lib::error_code & ec )
inline

Converting a weak pointer to shared_ptr is not thread safe because the pointer could be deleted at any time.

NOTE: This method may be called by handler to upgrade its handle to a full connection_ptr. That full connection may then be used safely for the remainder of the handler body. get_con_from_hdl and the resulting connection_ptr are NOT safe to use outside the handler loop.

Parameters
hdlThe connection handle to translate
Returns
the connection_ptr. May be NULL if the handle was invalid.

Definition at line 643 of file endpoint.hpp.

643 {
644 connection_ptr con = lib::static_pointer_cast<connection_type>(
645 hdl.lock());
646 if (!con) {
648 }
649 return con;
650 }
lib::error_code make_error_code(error::value e)
Definition error.hpp:235
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_elog()

template<typename connection , typename config >
elog_type & websocketpp::endpoint< connection, config >::get_elog ( )
inline
Returns
A reference to the error logger

Definition at line 269 of file endpoint.hpp.

269 {
270 return m_elog;
271 }

◆ get_max_http_body_size()

template<typename connection , typename config >
size_t websocketpp::endpoint< connection, config >::get_max_http_body_size ( ) const
inline

Get maximum HTTP message body size. Maximum message body size determines the point at which the connection will stop reading an HTTP request whose body is too large.

The default is set by the max_http_body_size value from the template config

Since
0.5.0
Returns
The maximum HTTP message body size

Definition at line 449 of file endpoint.hpp.

449 {
450 return m_max_http_body_size;
451 }

◆ get_max_message_size()

template<typename connection , typename config >
size_t websocketpp::endpoint< connection, config >::get_max_message_size ( ) const
inline

Get the default maximum message size that will be used for new connections created by this endpoint. The maximum message size determines the point at which the connection will fail a connection with the message_too_big protocol error.

The default is set by the max_message_size value from the template config

Since
0.3.0

Definition at line 415 of file endpoint.hpp.

415 {
416 return m_max_message_size;
417 }

◆ get_user_agent()

template<typename connection , typename config >
std::string websocketpp::endpoint< connection, config >::get_user_agent ( ) const
inline

Returns the user agent string that this endpoint will use when creating new connections.

The default value for this version is stored in websocketpp::user_agent

Returns
The user agent string.

Definition at line 169 of file endpoint.hpp.

169 {
170 scoped_lock_type guard(m_mutex);
171 return m_user_agent;
172 }
concurrency_type::scoped_lock_type scoped_lock_type
Type of our concurrency policy's scoped lock object.
Definition endpoint.hpp:78

◆ interrupt() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::interrupt ( connection_hdl hdl)

Definition at line 107 of file endpoint_impl.hpp.

107 {
108 lib::error_code ec;
109 interrupt(hdl,ec);
110 if (ec) { throw exception(ec); }
111}
void interrupt(connection_hdl hdl, lib::error_code &ec)

◆ interrupt() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::interrupt ( connection_hdl hdl,
lib::error_code & ec )

These functions act as adaptors to their counterparts in connection. They can produce one additional type of error, the bad_connection error, that indicates that the conversion from connection_hdl to connection_ptr failed due to the connection not existing anymore. Each method has a default and an exception free varient.

Definition at line 96 of file endpoint_impl.hpp.

97{
98 connection_ptr con = get_con_from_hdl(hdl,ec);
99 if (ec) {return;}
100
101 m_alog.write(log::alevel::devel,"Interrupting connection");
102
103 ec = con->interrupt();
104}

◆ is_server()

template<typename connection , typename config >
bool websocketpp::endpoint< connection, config >::is_server ( ) const
inline
Returns
Whether or not this endpoint is a server

Definition at line 205 of file endpoint.hpp.

205 {
206 return m_is_server;
207 }

◆ pause_reading() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::pause_reading ( connection_hdl hdl)

Definition at line 123 of file endpoint_impl.hpp.

123 {
124 lib::error_code ec;
125 pause_reading(hdl,ec);
126 if (ec) { throw exception(ec); }
127}
void pause_reading(connection_hdl hdl, lib::error_code &ec)
Pause reading of new data (exception free)

◆ pause_reading() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::pause_reading ( connection_hdl hdl,
lib::error_code & ec )

Signals to the connection to halt reading of new data. While reading is paused, the connection will stop reading from its associated socket. In turn this will result in TCP based flow control kicking in and slowing data flow from the remote endpoint.

This is useful for applications that push new requests to a queue to be processed by another thread and need a way to signal when their request queue is full without blocking the network processing thread.

Use resume_reading() to resume.

If supported by the transport this is done asynchronously. As such reading may not stop until the current read operation completes. Typically you can expect to receive no more bytes after initiating a read pause than the size of the read buffer.

If reading is paused for this connection already nothing is changed.

Definition at line 114 of file endpoint_impl.hpp.

115{
116 connection_ptr con = get_con_from_hdl(hdl,ec);
117 if (ec) {return;}
118
119 ec = con->pause_reading();
120}

◆ ping() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::ping ( connection_hdl hdl,
std::string const & payload )

Exception variant of ping

Since
0.3.0-alpha3
Parameters
[in]hdlThe connection_hdl of the connection to send to.
[in]payloadThe payload string to send.

Definition at line 243 of file endpoint_impl.hpp.

244{
245 lib::error_code ec;
246 ping(hdl,payload,ec);
247 if (ec) { throw exception(ec); }
248}
void ping(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a ping to a specific connection.

◆ ping() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::ping ( connection_hdl hdl,
std::string const & payload,
lib::error_code & ec )
Since
0.3.0-alpha3
Parameters
[in]hdlThe connection_hdl of the connection to send to.
[in]payloadThe payload string to send.
[out]ecA reference to an error code to fill in

Definition at line 234 of file endpoint_impl.hpp.

236{
237 connection_ptr con = get_con_from_hdl(hdl,ec);
238 if (ec) {return;}
239 con->ping(payload,ec);
240}

◆ pong() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::pong ( connection_hdl hdl,
std::string const & payload )

Exception variant of pong

Since
0.3.0-alpha3
Parameters
[in]hdlThe connection_hdl of the connection to send to.
[in]payloadThe payload string to send.

Definition at line 260 of file endpoint_impl.hpp.

261{
262 lib::error_code ec;
263 pong(hdl,payload,ec);
264 if (ec) { throw exception(ec); }
265}
void pong(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a pong to a specific connection.

◆ pong() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::pong ( connection_hdl hdl,
std::string const & payload,
lib::error_code & ec )
Since
0.3.0-alpha3
Parameters
[in]hdlThe connection_hdl of the connection to send to.
[in]payloadThe payload string to send.
[out]ecA reference to an error code to fill in

Definition at line 251 of file endpoint_impl.hpp.

253{
254 connection_ptr con = get_con_from_hdl(hdl,ec);
255 if (ec) {return;}
256 con->pong(payload,ec);
257}

◆ resume_reading() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::resume_reading ( connection_hdl hdl)

Definition at line 139 of file endpoint_impl.hpp.

139 {
140 lib::error_code ec;
141 resume_reading(hdl,ec);
142 if (ec) { throw exception(ec); }
143}
void resume_reading(connection_hdl hdl, lib::error_code &ec)
Resume reading of new data (exception free)

◆ resume_reading() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::resume_reading ( connection_hdl hdl,
lib::error_code & ec )

Signals to the connection to resume reading of new data after it was paused by pause_reading().

If reading is not paused for this connection already nothing is changed.

Definition at line 130 of file endpoint_impl.hpp.

131{
132 connection_ptr con = get_con_from_hdl(hdl,ec);
133 if (ec) {return;}
134
135 ec = con->resume_reading();
136}

◆ send() [1/6]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send ( connection_hdl hdl,
message_ptr msg )

Definition at line 208 of file endpoint_impl.hpp.

208 {
209 lib::error_code ec;
210 send(hdl,msg,ec);
211 if (ec) { throw exception(ec); }
212}
void send(connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
Create a message and add it to the outgoing send queue (exception free)

◆ send() [2/6]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send ( connection_hdl hdl,
message_ptr msg,
lib::error_code & ec )

Definition at line 199 of file endpoint_impl.hpp.

201{
202 connection_ptr con = get_con_from_hdl(hdl,ec);
203 if (ec) {return;}
204 ec = con->send(msg);
205}

◆ send() [3/6]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send ( connection_hdl hdl,
std::string const & payload,
frame::opcode::value op )

Convenience method to send a message given a payload string and an opcode

Parameters
[in]hdlThe handle identifying the connection to send via.
[in]payloadThe payload string to generated the message with
[in]opThe opcode to generated the message with.
[out]ecA code to fill in for errors

Definition at line 172 of file endpoint_impl.hpp.

174{
175 lib::error_code ec;
176 send(hdl,payload,op,ec);
177 if (ec) { throw exception(ec); }
178}

◆ send() [4/6]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send ( connection_hdl hdl,
std::string const & payload,
frame::opcode::value op,
lib::error_code & ec )

Convenience method to send a message given a payload string and an opcode

Parameters
[in]hdlThe handle identifying the connection to send via.
[in]payloadThe payload string to generated the message with
[in]opThe opcode to generated the message with.
[out]ecA code to fill in for errors

Definition at line 162 of file endpoint_impl.hpp.

164{
165 connection_ptr con = get_con_from_hdl(hdl,ec);
166 if (ec) {return;}
167
168 ec = con->send(payload,op);
169}
Here is the caller graph for this function:

◆ send() [5/6]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send ( connection_hdl hdl,
void const * payload,
size_t len,
frame::opcode::value op )

Definition at line 190 of file endpoint_impl.hpp.

192{
193 lib::error_code ec;
194 send(hdl,payload,len,op,ec);
195 if (ec) { throw exception(ec); }
196}
size_t len

◆ send() [6/6]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send ( connection_hdl hdl,
void const * payload,
size_t len,
frame::opcode::value op,
lib::error_code & ec )

Definition at line 181 of file endpoint_impl.hpp.

183{
184 connection_ptr con = get_con_from_hdl(hdl,ec);
185 if (ec) {return;}
186 ec = con->send(payload,len,op);
187}

◆ send_http_response() [1/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send_http_response ( connection_hdl hdl)

Sends an http response to an HTTP connection that was deferred. This will send a complete response including all headers, status line, and body text. The connection will be closed afterwards.

Exception variant

Since
0.6.0
Parameters
hdlThe connection to send the response on

Definition at line 155 of file endpoint_impl.hpp.

155 {
156 lib::error_code ec;
157 send_http_response(hdl,ec);
158 if (ec) { throw exception(ec); }
159}
void send_http_response(connection_hdl hdl, lib::error_code &ec)
Send deferred HTTP Response.

◆ send_http_response() [2/2]

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::send_http_response ( connection_hdl hdl,
lib::error_code & ec )

Sends an http response to an HTTP connection that was deferred. This will send a complete response including all headers, status line, and body text. The connection will be closed afterwards.

Exception free variant

Since
0.6.0
Parameters
hdlThe connection to send the response on
ecA status code, zero on success, non-zero otherwise

Definition at line 146 of file endpoint_impl.hpp.

148{
149 connection_ptr con = get_con_from_hdl(hdl,ec);
150 if (ec) {return;}
151 con->send_http_response(ec);
152}

◆ set_access_channels()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_access_channels ( log::level channels)
inline

Set the access logger's channel value. The value is a number whose interpretation depends on the logging policy in use.

Parameters
channelsThe channel value(s) to set

Definition at line 220 of file endpoint.hpp.

220 {
221 m_alog.set_channels(channels);
222 }
Here is the caller graph for this function:

◆ set_close_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_close_handler ( close_handler h)
inline

Definition at line 282 of file endpoint.hpp.

282 {
283 m_alog.write(log::alevel::devel,"set_close_handler");
284 scoped_lock_type guard(m_mutex);
285 m_close_handler = h;
286 }
Here is the caller graph for this function:

◆ set_close_handshake_timeout()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_close_handshake_timeout ( long dur)
inline

Sets the length of time the library will wait after a closing handshake has been initiated before cancelling it. This can be used to prevent excessive wait times for outgoing clients or excessive resource usage from broken clients or DoS attacks on servers.

Connections that time out will have their close handlers called with the close_handshake_timeout error code.

The default value is specified via the compile time config value 'timeout_close_handshake'. The default value in the core config is 5000ms. A value of 0 will disable the timer entirely.

To be effective, the transport you are using must support timers. See the documentation for your transport policy for details about its timer support.

Parameters
durThe length of the close handshake timeout in ms

Definition at line 377 of file endpoint.hpp.

377 {
378 scoped_lock_type guard(m_mutex);
379 m_close_handshake_timeout_dur = dur;
380 }

◆ set_error_channels()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_error_channels ( log::level channels)
inline

Set the error logger's channel value. The value is a number whose interpretation depends on the logging policy in use.

Parameters
channelsThe channel value(s) to set

Definition at line 242 of file endpoint.hpp.

242 {
243 m_elog.set_channels(channels);
244 }
Here is the caller graph for this function:

◆ set_fail_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_fail_handler ( fail_handler h)
inline

Definition at line 287 of file endpoint.hpp.

287 {
288 m_alog.write(log::alevel::devel,"set_fail_handler");
289 scoped_lock_type guard(m_mutex);
290 m_fail_handler = h;
291 }
Here is the caller graph for this function:

◆ set_http_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_http_handler ( http_handler h)
inline

Definition at line 312 of file endpoint.hpp.

312 {
313 m_alog.write(log::alevel::devel,"set_http_handler");
314 scoped_lock_type guard(m_mutex);
315 m_http_handler = h;
316 }
Here is the caller graph for this function:

◆ set_interrupt_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_interrupt_handler ( interrupt_handler h)
inline

Definition at line 307 of file endpoint.hpp.

307 {
308 m_alog.write(log::alevel::devel,"set_interrupt_handler");
309 scoped_lock_type guard(m_mutex);
310 m_interrupt_handler = h;
311 }

◆ set_max_http_body_size()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_max_http_body_size ( size_t new_value)
inline

Set maximum HTTP message body size. Maximum message body size determines the point at which the connection will stop reading an HTTP request whose body is too large.

The default is set by the max_http_body_size value from the template config

Since
0.5.1
Parameters
new_valueThe value to set as the maximum message size.

Definition at line 466 of file endpoint.hpp.

466 {
467 m_max_http_body_size = new_value;
468 }

◆ set_max_message_size()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_max_message_size ( size_t new_value)
inline

Set the default maximum message size that will be used for new connections created by this endpoint. Maximum message size determines the point at which the connection will fail a connection with the message_too_big protocol error.

The default is set by the max_message_size value from the template config

Since
0.3.0
Parameters
new_valueThe value to set as the maximum message size.

Definition at line 432 of file endpoint.hpp.

432 {
433 m_max_message_size = new_value;
434 }

◆ set_message_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_message_handler ( message_handler h)
inline

Definition at line 322 of file endpoint.hpp.

322 {
323 m_alog.write(log::alevel::devel,"set_message_handler");
324 scoped_lock_type guard(m_mutex);
325 m_message_handler = h;
326 }
Here is the caller graph for this function:

◆ set_open_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_open_handler ( open_handler h)
inline

Definition at line 277 of file endpoint.hpp.

277 {
278 m_alog.write(log::alevel::devel,"set_open_handler");
279 scoped_lock_type guard(m_mutex);
280 m_open_handler = h;
281 }
Here is the caller graph for this function:

◆ set_open_handshake_timeout()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_open_handshake_timeout ( long dur)
inline

Sets the length of time the library will wait after an opening handshake has been initiated before cancelling it. This can be used to prevent excessive wait times for outgoing clients or excessive resource usage from broken clients or DoS attacks on servers.

Connections that time out will have their fail handlers called with the open_handshake_timeout error code.

The default value is specified via the compile time config value 'timeout_open_handshake'. The default value in the core config is 5000ms. A value of 0 will disable the timer entirely.

To be effective, the transport you are using must support timers. See the documentation for your transport policy for details about its timer support.

Parameters
durThe length of the open handshake timeout in ms

Definition at line 352 of file endpoint.hpp.

352 {
353 scoped_lock_type guard(m_mutex);
354 m_open_handshake_timeout_dur = dur;
355 }

◆ set_ping_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_ping_handler ( ping_handler h)
inline

Definition at line 292 of file endpoint.hpp.

292 {
293 m_alog.write(log::alevel::devel,"set_ping_handler");
294 scoped_lock_type guard(m_mutex);
295 m_ping_handler = h;
296 }
Here is the caller graph for this function:

◆ set_pong_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_pong_handler ( pong_handler h)
inline

Definition at line 297 of file endpoint.hpp.

297 {
298 m_alog.write(log::alevel::devel,"set_pong_handler");
299 scoped_lock_type guard(m_mutex);
300 m_pong_handler = h;
301 }
Here is the caller graph for this function:

◆ set_pong_timeout()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_pong_timeout ( long dur)
inline

Sets the length of time the library will wait for a pong response to a ping. This can be used as a keepalive or to detect broken connections.

Pong responses that time out will have the pong timeout handler called.

The default value is specified via the compile time config value 'timeout_pong'. The default value in the core config is 5000ms. A value of 0 will disable the timer entirely.

To be effective, the transport you are using must support timers. See the documentation for your transport policy for details about its timer support.

Parameters
durThe length of the pong timeout in ms

Definition at line 399 of file endpoint.hpp.

399 {
400 scoped_lock_type guard(m_mutex);
401 m_pong_timeout_dur = dur;
402 }

◆ set_pong_timeout_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_pong_timeout_handler ( pong_timeout_handler h)
inline

Definition at line 302 of file endpoint.hpp.

302 {
303 m_alog.write(log::alevel::devel,"set_pong_timeout_handler");
304 scoped_lock_type guard(m_mutex);
305 m_pong_timeout_handler = h;
306 }
Here is the caller graph for this function:

◆ set_user_agent()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_user_agent ( std::string const & ua)
inline

Sets the identifier that this endpoint will use when creating new connections. Changing this value will only affect future connections. For client endpoints this will be sent as the "User-Agent" header in outgoing requests. For server endpoints this will be sent in the "Server" response header.

Setting this value to the empty string will suppress the use of the Server and User-Agent headers. This is typically done to hide implementation details for security purposes.

For best results set this before accepting or opening connections.

The default value for this version is stored in websocketpp::user_agent

This can be overridden on an individual connection basis by setting a custom "Server" header during the validate handler or "User-Agent" header on a connection before calling connect().

Parameters
uaThe string to set the user agent to.

Definition at line 196 of file endpoint.hpp.

196 {
197 scoped_lock_type guard(m_mutex);
198 m_user_agent = ua;
199 }
Here is the caller graph for this function:

◆ set_validate_handler()

template<typename connection , typename config >
void websocketpp::endpoint< connection, config >::set_validate_handler ( validate_handler h)
inline

Definition at line 317 of file endpoint.hpp.

317 {
318 m_alog.write(log::alevel::devel,"set_validate_handler");
319 scoped_lock_type guard(m_mutex);
320 m_validate_handler = h;
321 }
Here is the caller graph for this function:

Member Data Documentation

◆ m_alog

template<typename connection , typename config >
alog_type websocketpp::endpoint< connection, config >::m_alog
protected

Definition at line 664 of file endpoint.hpp.

◆ m_elog

template<typename connection , typename config >
elog_type websocketpp::endpoint< connection, config >::m_elog
protected

Definition at line 665 of file endpoint.hpp.


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