Skip to content

Commit

Permalink
Merge pull request #27 from meganz/hotfix/v0.9.9
Browse files Browse the repository at this point in the history
Avoid heartbeats during termination
  • Loading branch information
sergiohs84 authored Aug 1, 2017
2 parents 35ff258 + 3eaeba7 commit 2ff213b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/chatClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ void Client::heartbeat()
Client::~Client()
{
if (mHeartbeatTimer)
{
karere::cancelInterval(mHeartbeatTimer);
mHeartbeatTimer = 0;
}
//when the strophe::Connection is destroyed, its handlers are automatically destroyed
}

Expand Down Expand Up @@ -724,8 +727,19 @@ promise::Promise<void> Client::doConnect(Presence pres)
setConnState(kDisconnected);
});
assert(!mHeartbeatTimer);
mHeartbeatTimer = karere::setInterval([this]()
auto wptr = weakHandle();
mHeartbeatTimer = karere::setInterval([this, wptr]()
{
if (wptr.deleted())
{
return;
}

if (!mHeartbeatTimer)
{
return;
}

heartbeat();
}, 10000);
return pms;
Expand Down

0 comments on commit 2ff213b

Please sign in to comment.