From 30134f85451c01d463533d90ce1f374ec2657d61 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Fri, 1 Feb 2013 07:19:11 -0600 Subject: [PATCH] moves adaptor functions into endpoint_impl --- websocketpp/endpoint.hpp | 53 +++---------------------- websocketpp/impl/endpoint_impl.hpp | 64 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 47 deletions(-) diff --git a/websocketpp/endpoint.hpp b/websocketpp/endpoint.hpp index 3b49881d0e..de4b5f668b 100644 --- a/websocketpp/endpoint.hpp +++ b/websocketpp/endpoint.hpp @@ -254,63 +254,22 @@ public: /** * Is thread safe if transport is */ - void interrupt(connection_hdl hdl, lib::error_code & ec) { - connection_ptr con = get_con_from_hdl(hdl); - if (!con) { - ec = error::make_error_code(error::bad_connection); - return; - } - - m_alog.write(log::alevel::devel, - "Interrupting connection"+con.get()); - - ec = con->interrupt(); - } + void interrupt(connection_hdl hdl, lib::error_code & ec); /** * Is thread safe if transport is */ - void interrupt(connection_hdl hdl) { - lib::error_code ec; - interrupt(hdl,ec); - if (ec) { throw ec; } - } + void interrupt(connection_hdl hdl); void send(connection_hdl hdl, const std::string& payload, - frame::opcode::value op, lib::error_code & ec) - { - connection_ptr con = get_con_from_hdl(hdl); - if (!con) { - ec = error::make_error_code(error::bad_connection); - return; - } - - ec = con->send(payload,op); - } + frame::opcode::value op, lib::error_code & ec); void send(connection_hdl hdl, const std::string& payload, - frame::opcode::value op) - { - lib::error_code ec; - send(hdl,payload,op,ec); - if (ec) { throw ec; } - } + frame::opcode::value op); - void send(connection_hdl hdl, message_ptr msg, lib::error_code & ec) { - connection_ptr con = get_con_from_hdl(hdl); - if (!con) { - ec = error::make_error_code(error::bad_connection); - return; - } + void send(connection_hdl hdl, message_ptr msg, lib::error_code & ec); - ec = con->send(msg); - } - - void send(connection_hdl hdl, message_ptr msg) { - lib::error_code ec; - send(hdl,msg,ec); - if (ec) { throw ec; } - } + void send(connection_hdl hdl, message_ptr msg); protected: // Import appropriate internal types from our policy classes typedef typename concurrency_type::scoped_lock_type scoped_lock_type; diff --git a/websocketpp/impl/endpoint_impl.hpp b/websocketpp/impl/endpoint_impl.hpp index e99d0832d2..23e1c64013 100644 --- a/websocketpp/impl/endpoint_impl.hpp +++ b/websocketpp/impl/endpoint_impl.hpp @@ -87,6 +87,70 @@ endpoint::create_connection() { return con; } +template +void endpoint::interrupt(connection_hdl hdl, + lib::error_code & ec) +{ + connection_ptr con = get_con_from_hdl(hdl); + if (!con) { + ec = error::make_error_code(error::bad_connection); + return; + } + + m_alog.write(log::alevel::devel,"Interrupting connection"+con.get()); + + ec = con->interrupt(); +} + +template +void endpoint::interrupt(connection_hdl hdl) { + lib::error_code ec; + interrupt(hdl,ec); + if (ec) { throw ec; } +} + +template +void endpoint::send(connection_hdl hdl, + const std::string& payload, frame::opcode::value op, lib::error_code & ec) +{ + connection_ptr con = get_con_from_hdl(hdl); + if (!con) { + ec = error::make_error_code(error::bad_connection); + return; + } + + ec = con->send(payload,op); +} + +template +void endpoint::send(connection_hdl hdl, const std::string& + payload, frame::opcode::value op) +{ + lib::error_code ec; + send(hdl,payload,op,ec); + if (ec) { throw ec; } +} + +template +void endpoint::send(connection_hdl hdl, message_ptr msg, + lib::error_code & ec) +{ + connection_ptr con = get_con_from_hdl(hdl); + if (!con) { + ec = error::make_error_code(error::bad_connection); + return; + } + + ec = con->send(msg); +} + +template +void endpoint::send(connection_hdl hdl, message_ptr msg) { + lib::error_code ec; + send(hdl,msg,ec); + if (ec) { throw ec; } +} + template void endpoint::remove_connection(connection_ptr con) { std::stringstream s;