|
@@ -32,7 +32,6 @@ ChatServer::ChatServer( InitDatei *zIni )
|
|
|
db->setServerStatus( id, 2 );
|
|
|
end = 0;
|
|
|
nichtPausiert = 0;
|
|
|
- InitializeCriticalSection( &cs );
|
|
|
ref = 1;
|
|
|
if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
|
{
|
|
@@ -51,7 +50,6 @@ ChatServer::~ChatServer()
|
|
|
aServer->release();
|
|
|
ini->release();
|
|
|
db->release();
|
|
|
- DeleteCriticalSection( &cs );
|
|
|
if( klients )
|
|
|
klients->release();
|
|
|
}
|
|
@@ -87,10 +85,10 @@ void ChatServer::thread()
|
|
|
break;
|
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
CSKlient *clHandle = new CSKlient( klient, getThis() );
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
klients->set( clHandle, klientAnzahl );
|
|
|
klientAnzahl++;
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
clHandle->start();
|
|
|
}
|
|
|
}
|
|
@@ -102,12 +100,12 @@ void ChatServer::close()
|
|
|
#ifdef WIN32
|
|
|
warteAufThread( 1000 );
|
|
|
#endif
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
klients->z( i )->absturz();
|
|
|
klients = klients->release();
|
|
|
klientAnzahl = 0;
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
ende();
|
|
|
run = 0;
|
|
|
end = 1;
|
|
@@ -208,7 +206,7 @@ bool ChatServer::setMaxKlients( int mc )
|
|
|
bool ChatServer::absturzKlient( int klientId )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
{
|
|
|
if( klients->z( i )->getKlientNummer() == klientId )
|
|
@@ -220,14 +218,14 @@ bool ChatServer::absturzKlient( int klientId )
|
|
|
i--;
|
|
|
}
|
|
|
}
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
return gefunden;
|
|
|
}
|
|
|
|
|
|
bool ChatServer::removeAccount( int accId )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
{
|
|
|
if( klients->z( i )->getAccountId() == accId )
|
|
@@ -238,14 +236,14 @@ bool ChatServer::removeAccount( int accId )
|
|
|
i--;
|
|
|
}
|
|
|
}
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
return gefunden;
|
|
|
}
|
|
|
|
|
|
bool ChatServer::removeKlient( int klientId )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
{
|
|
|
if( klients->z( i )->getKlientNummer() == klientId )
|
|
@@ -257,14 +255,14 @@ bool ChatServer::removeKlient( int klientId )
|
|
|
i--;
|
|
|
}
|
|
|
}
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
return gefunden;
|
|
|
}
|
|
|
|
|
|
bool ChatServer::removeKlient( CSKlient *zKlient )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
{
|
|
|
if( klients->z( i ) == zKlient )
|
|
@@ -276,7 +274,7 @@ bool ChatServer::removeKlient( CSKlient *zKlient )
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
return gefunden;
|
|
|
}
|
|
|
|
|
@@ -294,7 +292,7 @@ int ChatServer::getKlientStatus( int klientNummer, CSKlient *zKlient )
|
|
|
{
|
|
|
bool empf = 0;
|
|
|
bool send = 0;
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
{
|
|
|
if( klients->z( i )->getKlientNummer() == klientNummer && klients->z( i ) != zKlient )
|
|
@@ -305,7 +303,7 @@ int ChatServer::getKlientStatus( int klientNummer, CSKlient *zKlient )
|
|
|
send = 1;
|
|
|
}
|
|
|
}
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
if( !empf )
|
|
|
return 0;
|
|
|
if( !send )
|
|
@@ -316,7 +314,7 @@ int ChatServer::getKlientStatus( int klientNummer, CSKlient *zKlient )
|
|
|
CSKlient *ChatServer::zSendeKlient( int accountId )
|
|
|
{
|
|
|
CSKlient *ret = 0;
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ cs.lock();
|
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
|
{
|
|
|
if( klients->z( i )->getAccountId() == accountId && !klients->z( i )->istEmpfang() )
|
|
@@ -325,7 +323,7 @@ CSKlient *ChatServer::zSendeKlient( int accountId )
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ cs.unlock();
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -676,14 +674,13 @@ CSKlient::CSKlient( SKlient *klient, ChatServer *cs )
|
|
|
: Thread()
|
|
|
{
|
|
|
this->klient = klient;
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
klientNummer = 0;
|
|
|
this->cs = cs;
|
|
|
accountId = 0;
|
|
|
empfangen = 1;
|
|
|
- InitializeCriticalSection( &ts );
|
|
|
ref = 1;
|
|
|
}
|
|
|
|
|
@@ -694,18 +691,17 @@ CSKlient::~CSKlient()
|
|
|
cs->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
klient->release();
|
|
|
cs->release();
|
|
|
- DeleteCriticalSection( &ts );
|
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
|
void CSKlient::lock()
|
|
|
{
|
|
|
- EnterCriticalSection( &ts );
|
|
|
+ ts.lock();
|
|
|
}
|
|
|
|
|
|
void CSKlient::unlock()
|
|
|
{
|
|
|
- LeaveCriticalSection( &ts );
|
|
|
+ ts.unlock();
|
|
|
}
|
|
|
|
|
|
void CSKlient::absturz()
|
|
@@ -2538,7 +2534,7 @@ bool MSGWeiterleitung::kickKlient( int accountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2588,7 +2584,7 @@ bool MSGWeiterleitung::accountOnline( int accountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2641,7 +2637,7 @@ bool MSGWeiterleitung::accountOffline( int accountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2692,7 +2688,7 @@ bool MSGWeiterleitung::chatNachricht( int vonAccount, int zuAccount, const char
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2748,7 +2744,7 @@ bool MSGWeiterleitung::accountStatusChange( int accountId, const char *status )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2806,7 +2802,7 @@ bool MSGWeiterleitung::accountNameChange( int accountId, const char *name )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2856,7 +2852,7 @@ bool MSGWeiterleitung::accountKeinFreundMehr( int accountId, int zielAccountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2902,7 +2898,7 @@ bool MSGWeiterleitung::freundesAnfrage( int vonAccountId, int zuAccountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2948,7 +2944,7 @@ bool MSGWeiterleitung::neuerFreund( int accountId, int zuAccountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -2994,7 +2990,7 @@ bool MSGWeiterleitung::einladungZumChatroom( int vonAccountId, int zuAccountId,
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3048,7 +3044,7 @@ bool MSGWeiterleitung::spielerBetrittChatroom( int accountId, int chatroomId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3105,7 +3101,7 @@ bool MSGWeiterleitung::chatroomNachricht( int vonAccount, const char *nachricht,
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3161,7 +3157,7 @@ bool MSGWeiterleitung::spielerLeavestChatroom( int accountId, int chatroomId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3210,7 +3206,7 @@ bool MSGWeiterleitung::freundEinladungAbgelehnt( int accountId, int zuAccountId
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3256,7 +3252,7 @@ bool MSGWeiterleitung::chatroomEinladungAbgelehnt( int accountId, int chatroomId
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3306,7 +3302,7 @@ bool MSGWeiterleitung::fehler( int zuAccountId, const char *fehler )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3353,7 +3349,7 @@ bool MSGWeiterleitung::chatroomAdmin( int chatroomId, int zuAccountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|
|
@@ -3399,7 +3395,7 @@ bool MSGWeiterleitung::chatroomKick( int chatroomId, int accountId )
|
|
|
if( ip )
|
|
|
{
|
|
|
klient = new Klient();
|
|
|
- unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
klient->setSendeKey( (char*)key, 20 );
|
|
|
klient->setEmpfangKey( (char*)key, 20 );
|
|
|
ret = ret & klient->verbinde( port, ip );
|