updates asio on_tcp_init callback to new api

This commit is contained in:
Peter Thorson
2013-01-06 10:10:35 -06:00
parent ce7b09767a
commit f5d4cbe143
3 changed files with 10 additions and 3 deletions

View File

@@ -85,6 +85,10 @@ void on_interrupt(server* s, websocketpp::connection_hdl hdl) {
std::cout << "on_interrupt called with hdl: " << hdl.lock().get() << std::endl;
}
void on_tcp_init(websocketpp::connection_hdl hdl) {
std::cout << "on_tcp_init called with hdl: " << hdl.lock().get() << std::endl;
}
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::bind;
@@ -101,6 +105,7 @@ int main() {
//echo_server.set_open_handler(websocketpp::lib::bind(&test_handler::on_open,t,websocketpp::lib::placeholders::_1));
echo_server.set_open_handler(bind(&on_open,&echo_server,::_1));
echo_server.set_interrupt_handler(bind(&on_interrupt,&echo_server,::_1));
echo_server.set_tcp_init_handler(&on_tcp_init);
// Listen
echo_server.listen(9002);

View File

@@ -57,7 +57,6 @@ public:
class handler_interface : public security_type::handler_interface {
public:
virtual void on_tcp_init() {};
};
typedef lib::shared_ptr<handler_interface> handler_ptr;
@@ -120,8 +119,8 @@ protected:
}
void handle_init(init_handler callback, const lib::error_code& ec) {
if (!ec) {
m_handler->on_tcp_init();
if (m_tcp_init_handler) {
m_tcp_init_handler(m_connection_hdl);
}
callback(ec);

View File

@@ -160,6 +160,9 @@ public:
* @see WebSocket++ handler documentation for more information about
* handlers.
*/
void set_tcp_init_handler(tcp_init_handler h) {
m_tcp_init_handler = h;
}
// listen manually
void listen(const boost::asio::ip::tcp::endpoint& e) {