28#ifndef WEBSOCKETPP_TRANSPORT_SECURITY_NONE_HPP
29#define WEBSOCKETPP_TRANSPORT_SECURITY_NONE_HPP
47namespace basic_socket {
50typedef lib::function<void(
connection_hdl,lib::asio::ip::tcp::socket&)>
58class connection :
public lib::enable_shared_from_this<connection> {
63 typedef lib::shared_ptr<type>
ptr;
68 typedef lib::shared_ptr<lib::asio::io_service::strand>
strand_ptr;
81 return shared_from_this();
101 m_socket_init_handler = h;
141 lib::asio::error_code aec;
142 lib::asio::ip::tcp::endpoint ep = m_socket->remote_endpoint(aec);
146 s <<
"Error getting remote endpoint: " << aec
147 <<
" (" << aec.message() <<
")";
150 ec = lib::error_code();
167 if (m_state != UNINITIALIZED) {
171 m_socket = lib::make_shared<lib::asio::ip::tcp::socket>(*service);
175 return lib::error_code();
201 if (m_state != READY) {
206 if (m_socket_init_handler) {
207 m_socket_init_handler(m_hdl,*m_socket);
212 callback(lib::error_code());
224 callback(lib::error_code());
248 lib::asio::error_code ec;
249 m_socket->cancel(ec);
254 lib::asio::error_code ec;
255 m_socket->shutdown(lib::asio::ip::tcp::socket::shutdown_both, ec);
260 return lib::error_code();
281 template <
typename ErrorCodeType>
344 m_socket_init_handler = h;
357 scon->set_socket_init_handler(m_socket_init_handler);
358 return lib::error_code();
Basic Asio connection socket component.
lib::asio::ip::tcp::socket socket_type
Type of the ASIO socket being used.
lib::asio::ip::tcp::socket & get_raw_socket()
Retrieve a pointer to the underlying socket.
void set_socket_init_handler(socket_init_handler h)
Set the socket initialization handler.
void set_uri(uri_ptr)
Set uri hook.
lib::shared_ptr< lib::asio::io_service::strand > strand_ptr
Type of a pointer to the Asio io_service strand being used.
lib::error_code translate_ec(ErrorCodeType)
Translate any security policy specific information about an error code.
lib::asio::io_service * io_service_ptr
Type of a pointer to the Asio io_service being used.
lib::asio::ip::tcp::socket & get_socket()
Retrieve a pointer to the underlying socket.
bool is_secure() const
Check whether or not this connection is secure.
connection type
Type of this connection socket component.
lib::error_code translate_ec(lib::error_code ec)
lib::error_code get_ec() const
void set_handle(connection_hdl hdl)
Sets the connection handle.
lib::asio::error_code cancel_socket()
Cancel all async operations on this socket.
lib::shared_ptr< socket_type > socket_ptr
Type of a shared pointer to the socket being used.
void pre_init(init_handler callback)
Pre-initialize security policy.
std::string get_remote_endpoint(lib::error_code &ec) const
Get the remote endpoint address.
void post_init(init_handler callback)
Post-initialize security policy.
lib::error_code init_asio(io_service_ptr service, strand_ptr, bool)
Perform one time initializations.
void async_shutdown(socket::shutdown_handler h)
ptr get_shared()
Get a shared pointer to this component.
lib::shared_ptr< type > ptr
Type of a shared pointer to this connection socket component.
lib::asio::ip::tcp::socket & get_next_layer()
Retrieve a pointer to the underlying socket.
Basic ASIO endpoint socket component.
void set_socket_init_handler(socket_init_handler h)
Set socket init handler.
endpoint type
The type of this endpoint socket component.
socket_con_type::ptr socket_con_ptr
lib::error_code init(socket_con_ptr scon)
Initialize a connection.
connection socket_con_type
The type of the corresponding connection socket component.
bool is_secure() const
Checks whether the endpoint creates secure connections.
lib::function< void(connection_hdl, lib::asio::ip::tcp::socket &)> socket_init_handler
The signature of the socket init handler for this socket policy.
@ invalid_state
A function was called in a state that it was illegal to do so.
lib::function< void(lib::asio::error_code const &)> shutdown_handler
lib::error_code make_error_code(error::value e)
@ pass_through
underlying transport pass through
lib::function< void(lib::error_code const &)> init_handler
The type and signature of the callback passed to the init hook.
Namespace for the WebSocket++ project.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.