/*

MAgen.dll: Miranda plugin for mail.ru message exchange.

Copyright 2005-2010 Lenik.
Project home at http://www.lenik.ru/win32/magent
Author contact: lenik@lenik.ru

This program is free software.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

*/

struct WatchDogThread_Data
    {
    unsigned long thid;
    };

void WatchDogThread(struct WatchDogThread_Data *p)
{
static mrim_packet_header_t hdr;

#ifdef MRIM_DEBUG
    PrintDebug("WatchDogThread: started\n");
#endif
Sleep(500 * MRIM_WatchDogInterval);
while(1)
    {
    hdr.magic = CS_MAGIC;
    hdr.proto = PROTO_VERSION;
    hdr.seq = GetSequenceNext();
    hdr.msg = MRIM_CS_PING;
    hdr.dlen = 0;
    hdr.from = 0;
    hdr.fromport = 0;

    #ifdef MRIM_DEBUG
        PrintDebug("WatchDogThread: MRIM_CS_PING sending\n");
    #endif
    MRIM_sendpacket(&hdr);

    #ifdef MRIM_DEBUG
        PrintDebug("WatchDogThread: Sleeping %lu sec\n",MRIM_WatchDogInterval);
    #endif
    Sleep(1000 * MRIM_WatchDogInterval);
    }
}
