diff options
author | eidheim <eidheim@gmail.com> | 2017-07-19 12:31:52 +0300 |
---|---|---|
committer | eidheim <eidheim@gmail.com> | 2017-07-19 12:31:52 +0300 |
commit | b91694ae8691f26e614d1b2001f2ced41c8c07bf (patch) | |
tree | 57b5668ab9bd95357fa760bec83f575081f4843d /client_wss.hpp | |
parent | 6deb487a1ab266b9d7347f4e1d9fafc07e267c23 (diff) |
Added Client::Connection as argument for Client event functions
Diffstat (limited to 'client_wss.hpp')
-rw-r--r-- | client_wss.hpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/client_wss.hpp b/client_wss.hpp index a00ffef..b2f8845 100644 --- a/client_wss.hpp +++ b/client_wss.hpp @@ -45,11 +45,10 @@ namespace SimpleWeb { asio::ip::tcp::resolver::query query(host, std::to_string(port)); auto resolver = std::make_shared<asio::ip::tcp::resolver>(*io_service); resolver->async_resolve(query, [this, resolver](const error_code &ec, asio::ip::tcp::resolver::iterator it) { + std::unique_lock<std::mutex> lock(connection_mutex); + auto connection = this->connection = std::shared_ptr<Connection>(new Connection(*io_service, context)); + lock.unlock(); if(!ec) { - std::unique_lock<std::mutex> lock(connection_mutex); - auto connection = this->connection = std::shared_ptr<Connection>(new Connection(*io_service, context)); - lock.unlock(); - asio::async_connect(connection->socket->lowest_layer(), it, [this, connection, resolver](const error_code &ec, asio::ip::tcp::resolver::iterator /*it*/) { if(!ec) { asio::ip::tcp::no_delay option(true); @@ -59,15 +58,15 @@ namespace SimpleWeb { if(!ec) handshake(connection); else if(on_error) - on_error(ec); + on_error(connection, ec); }); } else if(on_error) - on_error(ec); + on_error(connection, ec); }); } else if(on_error) - on_error(ec); + on_error(connection, ec); }); } }; |