diff --git a/examples/dev/main.cpp b/examples/dev/main.cpp index ebe7a75065..241f0f780b 100644 --- a/examples/dev/main.cpp +++ b/examples/dev/main.cpp @@ -23,7 +23,7 @@ //typedef websocketpp::server server; typedef websocketpp::server server; -class handler : public server::handler { +/*class handler : public server::handler { bool validate(connection_ptr con) { std::cout << "handler validate" << std::endl; if (con->get_origin() != "http://www.example.com") { @@ -60,7 +60,7 @@ class handler : public server::handler { void on_close(connection_ptr con) { std::cout << "handler on_close" << std::endl; } -}; +};*/ int main() { typedef websocketpp::message_buffer::message diff --git a/examples/echo_server/echo_server.cpp b/examples/echo_server/echo_server.cpp index 7d568fd2e7..d0a1057a62 100644 --- a/examples/echo_server/echo_server.cpp +++ b/examples/echo_server/echo_server.cpp @@ -6,7 +6,7 @@ typedef websocketpp::server server; -class handler : public server::handler { +/*class handler : public server::handler { bool validate(connection_ptr con) { std::cout << "handler validate" << std::endl; return true; @@ -62,7 +62,7 @@ class handler : public server::handler { void on_interrupt(connection_ptr con) { std::cout << "handler on_interrupt" << std::endl; } -}; +};*/ class test_handler { public: @@ -105,9 +105,7 @@ void on_message(server* s,websocketpp::connection_hdl hdl,message_ptr msg) { } int main() { - server::handler::ptr h(new handler()); - - server echo_server(h); + server echo_server; echo_server.init_asio(); diff --git a/examples/echo_server_tls/echo_server_tls.cpp b/examples/echo_server_tls/echo_server_tls.cpp index c9355cb95a..4b701c98c5 100644 --- a/examples/echo_server_tls/echo_server_tls.cpp +++ b/examples/echo_server_tls/echo_server_tls.cpp @@ -6,7 +6,7 @@ typedef websocketpp::server server; -class handler : public server::handler { +/*class handler : public server::handler { std::string get_password() const { return "test"; @@ -62,12 +62,10 @@ class handler : public server::handler { void on_close(connection_ptr con) { std::cout << "handler on_close" << std::endl; } -}; +};*/ int main() { - server::handler::ptr h(new handler()); - - server echo_server(h); + server echo_server; echo_server.init_asio(); diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index cd463dfefd..11bda2a4cb 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -133,39 +133,6 @@ public: typedef lib::function termination_handler; - class handler { - public: - typedef handler type; - typedef lib::shared_ptr ptr; - typedef lib::weak_ptr weak_ptr; - - typedef typename connection::ptr connection_ptr; - typedef typename config::message_type::ptr message_ptr; - - //virtual void http(connection_ptr con) {} - - // TODO: validate is server only. hide from client handlers? - //virtual bool validate(connection_ptr con) {return true;} - - //virtual void on_inturrupt(connection_ptr con) {} - - //virtual void on_open(connection_ptr con) {} - //virtual void on_fail(connection_ptr con) {} - virtual void on_message(connection_ptr con, message_ptr msg) {} - //virtual void on_close(connection_ptr con) {} - - //virtual bool on_ping(connection_ptr con, const std::string &) { - // return true; - //} - //virtual void on_pong(connection_ptr con, const std::string &) {} - //virtual void on_pong_timeout(connection_ptr con, const std::string &) {} - - virtual void on_load(connection_ptr con, ptr old_handler) {} - virtual void on_unload(connection_ptr con, ptr new_handler) {} - }; - - typedef typename handler::ptr handler_ptr; - typedef typename concurrency_type::scoped_lock_type scoped_lock_type; typedef typename concurrency_type::mutex_type mutex_type; @@ -352,23 +319,6 @@ public: void set_message_handler(message_handler h) { m_message_handler = h; } - - /// Set new connection handler - /** - * Will invoke the old handler's on_unload callback followed by the - * new handler's on_load callback. These callbacks will both happen - * immediately and before set_handler returns. If called in a method - * within the connection's strand (such as another callback) the - * next callback run after the present one will use the new state - * including ones that are on the asio stack already but not yet - * scheduled. - * - * This method may be called at any time. - * - * @param new_handler The new handler to switch to. - */ - void set_handler(handler_ptr new_handler); - /// Return the same origin policy origin value from the opening request. /** @@ -847,9 +797,6 @@ private: validate_handler m_validate_handler; message_handler m_message_handler; - /// Legacy Handler - handler_ptr m_handler; - /// External connection state /** * Lock: m_connection_state_lock diff --git a/websocketpp/endpoint.hpp b/websocketpp/endpoint.hpp index c609532d51..de1ed11782 100644 --- a/websocketpp/endpoint.hpp +++ b/websocketpp/endpoint.hpp @@ -69,15 +69,12 @@ public: typedef typename connection_type::message_handler message_handler; // TODO: organize these - typedef typename connection_type::handler handler_type; - typedef typename handler_type::ptr handler_ptr; typedef typename connection_type::termination_handler termination_handler; typedef lib::shared_ptr hdl_type; - explicit endpoint(handler_ptr default_handler, bool is_server) - : m_default_handler(default_handler) - , m_user_agent(::websocketpp::user_agent) + explicit endpoint(bool is_server) + : m_user_agent(::websocketpp::user_agent) , m_is_server(is_server) { std::cout << "endpoint constructor" << std::endl; @@ -177,7 +174,6 @@ protected: mutex_type m_mutex; private: // dynamic settings - handler_ptr m_default_handler; std::string m_user_agent; open_handler m_open_handler; diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 0c3ac0d4fa..39fb0da7c0 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -41,27 +41,6 @@ namespace websocketpp { namespace istate = session::internal_state; -template -void connection::set_handler(handler_ptr new_handler) { - std::cout << "connection set_handler" << std::endl; - //scoped_lock_type lock(m_connection_state_lock); - - if (!new_handler) { - // TODO - throw std::logic_error("set_handler"); - } - - handler_ptr old_handler = m_handler; - if (old_handler) { - old_handler->on_unload(type::shared_from_this(),new_handler); - } - m_handler = new_handler; - - new_handler->on_load(type::shared_from_this(),old_handler); -} - - - template void connection::set_termination_handler( termination_handler new_handler) @@ -468,8 +447,6 @@ void connection::handle_transport_init(const lib::error_code& ec) { // server: read/process/write/go // client: process/write/read/process/go - //m_handler->on_open(type::shared_from_this()); - //this->read(); } @@ -685,7 +662,6 @@ void connection::handle_read_frame(const lib::error_code& ec, std::cout << "null message from m_processor" << std::endl; } else if (!is_control(msg->get_opcode())) { // data message, dispatch to user - //m_handler->on_message(type::shared_from_this(), msg); if (m_message_handler) { m_message_handler(m_connection_hdl, msg); } @@ -845,6 +821,7 @@ bool connection::process_handshake_request() { return true; } +// TODO: does this function still need to be here? template void connection::handle_read(const lib::error_code& ec, size_t bytes_transferred) @@ -867,7 +844,7 @@ void connection::handle_read(const lib::error_code& ec, return; } - m_handler->on_message(type::shared_from_this(),foo); + //m_handler->on_message(type::shared_from_this(),foo); this->read(); } diff --git a/websocketpp/impl/endpoint_impl.hpp b/websocketpp/impl/endpoint_impl.hpp index 4bb7a408c8..0895625b42 100644 --- a/websocketpp/impl/endpoint_impl.hpp +++ b/websocketpp/impl/endpoint_impl.hpp @@ -55,8 +55,6 @@ endpoint::create_connection() { // con->set_handle(w); - con->set_handler(m_default_handler); - // Copy default handlers from the endpoint con->set_open_handler(m_open_handler); con->set_close_handler(m_close_handler); diff --git a/websocketpp/roles/server_endpoint.hpp b/websocketpp/roles/server_endpoint.hpp index 977b7ebdac..1e26376231 100644 --- a/websocketpp/roles/server_endpoint.hpp +++ b/websocketpp/roles/server_endpoint.hpp @@ -50,11 +50,6 @@ public: /// Type of the endpoint transport component typedef typename config::transport_type transport_type; - // connection policies - //typedef role::server role_con_policy; - //typedef concurrency_type concurrency_con_policy; - //typedef typename transport_type::con_policy transport_con_policy; - /// Type of the connections this server will create typedef connection connection_type; /// Type of a shared pointer to the connections this server will create @@ -70,12 +65,8 @@ public: // TODO: clean up these types - typedef typename endpoint_type::handler_type handler_type; - typedef handler_type handler; // for backwards compatibility - typedef typename endpoint_type::handler_ptr handler_ptr; - explicit server(typename endpoint_type::handler_ptr default_handler) - : endpoint_type(default_handler,true) + explicit server() : endpoint_type(true) { std::cout << "server constructor" << std::endl; }