28 #ifndef WEBSOCKETPP_ENDPOINT_IMPL_HPP
29 #define WEBSOCKETPP_ENDPOINT_IMPL_HPP
35 template <
typename connection,
typename config>
36 typename endpoint<connection,config>::connection_ptr
37 endpoint<connection,config>::create_connection() {
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));
50 connection_weak_ptr w(con);
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);
70 if (m_open_handshake_timeout_dur != config::timeout_open_handshake) {
71 con->set_open_handshake_timeout(m_open_handshake_timeout_dur);
73 if (m_close_handshake_timeout_dur != config::timeout_close_handshake) {
74 con->set_close_handshake_timeout(m_close_handshake_timeout_dur);
76 if (m_pong_timeout_dur != config::timeout_pong) {
77 con->set_pong_timeout(m_pong_timeout_dur);
79 if (m_max_message_size != config::max_message_size) {
80 con->set_max_message_size(m_max_message_size);
82 con->set_max_http_body_size(m_max_http_body_size);
86 ec = transport_type::init(con);
89 return connection_ptr();
95 template <
typename connection,
typename config>
103 ec = con->interrupt();
106 template <
typename connection,
typename config>
113 template <
typename connection,
typename config>
119 ec = con->pause_reading();
122 template <
typename connection,
typename config>
125 pause_reading(hdl,ec);
129 template <
typename connection,
typename config>
135 ec = con->resume_reading();
138 template <
typename connection,
typename config>
141 resume_reading(hdl,ec);
147 template <
typename connection,
typename config>
149 frame::opcode::value op, lib::error_code & ec)
154 ec = con->send(payload,op);
157 template <
typename connection,
typename config>
159 frame::opcode::value op)
162 send(hdl,payload,op,ec);
166 template <
typename connection,
typename config>
168 size_t len, frame::opcode::value op, lib::error_code & ec)
170 connection_ptr con = get_con_from_hdl(hdl,ec);
172 ec = con->send(payload,len,op);
175 template <
typename connection,
typename config>
177 size_t len, frame::opcode::value op)
180 send(hdl,payload,len,op,ec);
181 if (ec) {
throw exception(ec); }
184 template <
typename connection,
typename config>
186 lib::error_code & ec)
188 connection_ptr con = get_con_from_hdl(hdl,ec);
193 template <
typename connection,
typename config>
197 if (ec) {
throw exception(ec); }
200 template <
typename connection,
typename config>
202 const code, std::string
const & reason,
203 lib::error_code & ec)
205 connection_ptr con = get_con_from_hdl(hdl,ec);
207 con->close(code,reason,ec);
210 template <
typename connection,
typename config>
212 const code, std::string
const & reason)
215 close(hdl,code,reason,ec);
216 if (ec) {
throw exception(ec); }
219 template <
typename connection,
typename config>
221 payload, lib::error_code & ec)
225 con->ping(payload,ec);
228 template <
typename connection,
typename config>
232 ping(hdl,payload,ec);
236 template <
typename connection,
typename config>
238 lib::error_code & ec)
242 con->pong(payload,ec);
245 template <
typename connection,
typename config>
249 pong(hdl,payload,ec);
255 #endif // WEBSOCKETPP_ENDPOINT_IMPL_HPP
uint16_t value
The type of a close code value.
void ping(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a ping to a specific connection.
void interrupt(connection_hdl hdl, lib::error_code &ec)
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
void pause_reading(connection_hdl hdl, lib::error_code &ec)
Pause reading of new data (exception free)
static level const devel
Development messages (warning: very chatty)
void resume_reading(connection_hdl hdl, lib::error_code &ec)
Resume reading of new data (exception free)
connection_type::ptr connection_ptr
Shared pointer to connection_type.
void pong(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a pong to a specific connection.
Namespace for the WebSocket++ project.
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)