From 0d0add7b1272241fe4c90f09c7ca8be1762a3c6d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 16 Jul 2014 11:17:06 +0000 Subject: fix for keep-alive in ICQ git-svn-id: http://svn.miranda-ng.org/main/trunk@9827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/chan_05ping.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'protocols/IcqOscarJ/src/chan_05ping.cpp') diff --git a/protocols/IcqOscarJ/src/chan_05ping.cpp b/protocols/IcqOscarJ/src/chan_05ping.cpp index 5fe2aaf9a7..8e735337e8 100644 --- a/protocols/IcqOscarJ/src/chan_05ping.cpp +++ b/protocols/IcqOscarJ/src/chan_05ping.cpp @@ -32,27 +32,27 @@ void CIcqProto::handlePingChannel(BYTE *buf, WORD datalen) void CIcqProto::StartKeepAlive(serverthread_info *info) { if (getByte("KeepAlive", DEFAULT_KEEPALIVE_ENABLED)) - info->iKeepalive = getDword("KeepAliveInterval", KEEPALIVE_INTERVAL); + info->tmPing = time(0) + KEEPALIVE_INTERVAL; else - info->iKeepalive = -1; + info->tmPing = -1; } void CIcqProto::StopKeepAlive(serverthread_info *info) { - info->iKeepalive = -1; + info->tmPing = -1; } void CIcqProto::CheckKeepAlive(serverthread_info *info) { - if (info->iKeepalive != -1) { - if (info->iKeepalive == 0) { - // Send a keep alive packet to server - icq_packet packet = { 0 }; - write_flap(&packet, ICQ_PING_CHAN); - sendServPacket(&packet); + if (info->tmPing == -1) + return; - StartKeepAlive(info); - } - else info->iKeepalive--; + if (time(0) >= info->tmPing) { + // Send a keep alive packet to server + icq_packet packet = { 0 }; + write_flap(&packet, ICQ_PING_CHAN); + sendServPacket(&packet); + + StartKeepAlive(info); } } -- cgit v1.2.3