#include "KeepAlive.h"
#include "../Global/Variablen.h"

// Inhalt der KeepAliveTh Klasse aus KeepAlive.h
// Konstruktor
KeepAliveTh::KeepAliveTh()
	: Thread()
{
	exit = 0;
	start();
}

// nicht constant
void KeepAliveTh::thread()
{
	while( !exit )
	{
		if( loginKlient && loginKlient->istVerbunden() )
			loginKlient->keepAlive();
		if( registerKlient && registerKlient->istVerbunden() )
			registerKlient->keepAlive();
		if( infoKlient && infoKlient->istVerbunden() )
			infoKlient->keepAlive();
		if( chatKlient && chatKlient->istVerbunden() )
			chatKlient->keepAlive();
		if( anmeldungKlient && anmeldungKlient->istVerbunden() )
			anmeldungKlient->keepAlive();
		if( spielKlient && spielKlient->istVerbunden() )
			spielKlient->keepAlive();
		if( shopKlient && shopKlient->istVerbunden() )
			shopKlient->keepAlive();
		if( newsKlient && newsKlient->istVerbunden() )
            newsKlient->keepAlive();
        if( editorKlient && editorKlient->istVerbunden() )
            editorKlient->keepAlive();
        if( kartenKlient && kartenKlient->istVerbunden() )
            kartenKlient->keepAlive();
		for( int i = 0; i < 300 && !exit; i++ )
			Sleep( 100 );
	}
	run = 0;
}

void KeepAliveTh::doExit()
{
	exit = 1;
}