28 #ifndef WEBSOCKETPP_TRANSPORT_SECURITY_NONE_HPP
29 #define WEBSOCKETPP_TRANSPORT_SECURITY_NONE_HPP
31 #include <websocketpp/transport/asio/security/base.hpp>
33 #include <websocketpp/common/memory.hpp>
35 #include <boost/asio.hpp>
45 namespace basic_socket {
48 typedef lib::function<void(connection_hdl,boost::asio::ip::tcp::socket&)>
56 class connection :
public lib::enable_shared_from_this<connection> {
61 typedef lib::shared_ptr<type>
ptr;
66 typedef lib::shared_ptr<boost::asio::io_service::strand>
strand_ptr;
72 explicit connection() : m_state(UNINITIALIZED) {
79 return shared_from_this();
99 m_socket_init_handler = h;
139 boost::system::error_code bec;
140 boost::asio::ip::tcp::endpoint ep = m_socket->remote_endpoint(bec);
144 s <<
"Error getting remote endpoint: " << bec
145 <<
" (" << bec.message() <<
")";
148 ec = lib::error_code();
163 lib::error_code
init_asio (io_service_ptr service, strand_ptr,
bool)
165 if (m_state != UNINITIALIZED) {
169 m_socket = lib::make_shared<boost::asio::ip::tcp::socket>(
174 return lib::error_code();
187 if (m_state != READY) {
192 if (m_socket_init_handler) {
193 m_socket_init_handler(m_hdl,*m_socket);
198 callback(lib::error_code());
210 callback(lib::error_code());
229 void async_shutdown(socket_shutdown_handler h) {
230 boost::system::error_code ec;
231 m_socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both,ec);
235 lib::error_code get_ec()
const {
236 return lib::error_code();
304 m_socket_init_handler = h;
316 lib::error_code
init(socket_con_ptr scon) {
317 scon->set_socket_init_handler(m_socket_init_handler);
318 return lib::error_code();
329 #endif // WEBSOCKETPP_TRANSPORT_SECURITY_NONE_HPP
Basic Boost ASIO connection socket component.
void pre_init(init_handler callback)
Pre-initialize security policy.
void set_socket_init_handler(socket_init_handler h)
Set the socket initialization handler.
lib::error_code make_error_code(error::value e)
Create an error code with the given value and the asio transport category.
bool is_secure() const
Checks whether the endpoint creates secure connections.
lib::error_code init_asio(io_service_ptr service, strand_ptr, bool)
Perform one time initializations.
std::string get_remote_endpoint(lib::error_code &ec) const
Get the remote endpoint address.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
underlying transport pass through
lib::shared_ptr< boost::asio::io_service::strand > strand_ptr
Type of a pointer to the ASIO io_service strand being used.
boost::asio::ip::tcp::socket & get_socket()
Retrieve a pointer to the underlying socket.
lib::error_code init(socket_con_ptr scon)
Initialize a connection.
lib::error_code translate_ec(boost::system::error_code)
Translate any security policy specific information about an error code.
void cancel_socket()
Cancel all async operations on this socket.
A function was called in a state that it was illegal to do so.
ptr get_shared()
Get a shared pointer to this component.
boost::asio::ip::tcp::socket & get_raw_socket()
Retrieve a pointer to the underlying socket.
lib::shared_ptr< socket_type > socket_ptr
Type of a shared pointer to the socket being used.
there was an error in the underlying transport library
Namespace for the WebSocket++ project.
lib::function< void(lib::error_code const &)> init_handler
The type and signature of the callback passed to the init hook.
Basic ASIO endpoint socket component.
boost::asio::io_service * io_service_ptr
Type of a pointer to the ASIO io_service being used.
void post_init(init_handler callback)
Post-initialize security policy.
boost::asio::ip::tcp::socket socket_type
Type of the ASIO socket being used.
endpoint type
The type of this endpoint socket component.
lib::shared_ptr< type > ptr
Type of a shared pointer to this connection socket component.
void set_handle(connection_hdl hdl)
Sets the connection handle.
connection socket_con_type
The type of the corresponding connection socket component.
connection type
Type of this connection socket component.
bool is_secure() const
Check whether or not this connection is secure.
lib::function< void(connection_hdl, boost::asio::ip::tcp::socket &)> socket_init_handler
The signature of the socket init handler for this socket policy.
boost::asio::ip::tcp::socket & get_next_layer()
Retrieve a pointer to the underlying socket.
void set_socket_init_handler(socket_init_handler h)
Set socket init handler.
socket_con_type::ptr socket_con_ptr