Fixed disconnect

This commit is contained in:
BenDroid 2018-04-14 23:47:45 +02:00
parent 10163ffe94
commit 09548d6b3b
2 changed files with 10 additions and 6 deletions

View file

@ -36,7 +36,7 @@ public:
~BoostConnection()
{
disconnect();
}
void connect(const std::string& server, uint16_t port) override
@ -51,6 +51,8 @@ public:
boost::bind(&BoostConnection::handleConnect, this->shared_from_this(),
boost::asio::placeholders::error));
std::thread([this]() { ioService_.run(); }).detach();
}
@ -67,11 +69,8 @@ public:
void disconnect() override
{
if (isConnected()) {
LOG_DEBUG("[%s:%d] Disconnecting", getConnectedIp().c_str(), getConnectedPort());
socket_.get().lowest_layer().close();
}
LOG_DEBUG("[%s:%d] Disconnecting", getConnectedIp().c_str(), getConnectedPort());
socket_.get().lowest_layer().close();
ioService_.stop();
}