From dc3be3d658b49bda3f9a9f4ee5050813e187cd7d Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Fri, 13 Apr 2012 07:34:11 -0500 Subject: [PATCH] adds on_tcp_init hook --- src/sockets/plain.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sockets/plain.hpp b/src/sockets/plain.hpp index 8ea276f1d8..376fcb3bee 100644 --- a/src/sockets/plain.hpp +++ b/src/sockets/plain.hpp @@ -49,8 +49,11 @@ public: return false; } - // plain sockets do not add anything to the handler interface - class handler_interface {}; + // hooks that this policy adds to handlers of connections that use it + class handler_interface { + public: + virtual void on_tcp_init() {}; + }; // Connection specific details template @@ -69,13 +72,17 @@ public: return false; } protected: - connection(plain& e) : m_socket(e.get_io_service()) {} + connection(plain& e) + : m_socket(e.get_io_service()) + , m_connection(static_cast< connection_type& >(*this)) {} void init() { } void async_init(socket_init_callback callback) { + m_connection.get_handler()->on_tcp_init(); + // TODO: make configuration option for NO_DELAY m_socket.set_option(boost::asio::ip::tcp::no_delay(true)); @@ -95,6 +102,7 @@ public: } private: boost::asio::ip::tcp::socket m_socket; + connection_type& m_connection; }; protected: plain (boost::asio::io_service& m) : m_io_service(m) {}