|
@@ -11,7 +11,6 @@ AnmeldungServer::AnmeldungServer( InitDatei *zIni )
|
|
Network::Start( 100 );
|
|
Network::Start( 100 );
|
|
std::cout << "AS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
std::cout << "AS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
db = new ASDatenbank( zIni );
|
|
db = new ASDatenbank( zIni );
|
|
- klientAnzahl = 0;
|
|
|
|
klients = new RCArray< ASKlient >();
|
|
klients = new RCArray< ASKlient >();
|
|
empfangen = 0;
|
|
empfangen = 0;
|
|
gesendet = 0;
|
|
gesendet = 0;
|
|
@@ -87,8 +86,7 @@ void AnmeldungServer::thread()
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
ASKlient *clHandle = new ASKlient( klient, dynamic_cast<AnmeldungServer *>( getThis() ) );
|
|
ASKlient *clHandle = new ASKlient( klient, dynamic_cast<AnmeldungServer *>( getThis() ) );
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
- klients->set( clHandle, klientAnzahl );
|
|
|
|
- klientAnzahl++;
|
|
|
|
|
|
+ klients->add( clHandle );
|
|
LeaveCriticalSection( &cs );
|
|
LeaveCriticalSection( &cs );
|
|
clHandle->start();
|
|
clHandle->start();
|
|
}
|
|
}
|
|
@@ -102,10 +100,9 @@ void AnmeldungServer::close()
|
|
warteAufThread( 1000 );
|
|
warteAufThread( 1000 );
|
|
#endif
|
|
#endif
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
- klients->z( i )->absturz();
|
|
|
|
|
|
+ for( ASKlient *client : *klients )
|
|
|
|
+ client->absturz();
|
|
klients = ( RCArray<ASKlient>* )klients->release();
|
|
klients = ( RCArray<ASKlient>* )klients->release();
|
|
- klientAnzahl = 0;
|
|
|
|
LeaveCriticalSection( &cs );
|
|
LeaveCriticalSection( &cs );
|
|
ende();
|
|
ende();
|
|
run = 0;
|
|
run = 0;
|
|
@@ -207,13 +204,12 @@ bool AnmeldungServer::absturzKlient( int klientId )
|
|
{
|
|
{
|
|
bool gefunden = 0;
|
|
bool gefunden = 0;
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
|
|
+ for( int i = 0; i < klients->getEintragAnzahl(); i++ )
|
|
{
|
|
{
|
|
if( klients->z( i )->getKlientNummer() == klientId )
|
|
if( klients->z( i )->getKlientNummer() == klientId )
|
|
{
|
|
{
|
|
klients->z( i )->absturz();
|
|
klients->z( i )->absturz();
|
|
klients->remove( i );
|
|
klients->remove( i );
|
|
- klientAnzahl--;
|
|
|
|
gefunden = 1;
|
|
gefunden = 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -226,12 +222,11 @@ bool AnmeldungServer::removeKlient( ASKlient *zKlient )
|
|
{
|
|
{
|
|
bool gefunden = 0;
|
|
bool gefunden = 0;
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
|
|
+ for( int i = 0; i < klients->getEintragAnzahl(); i++ )
|
|
{
|
|
{
|
|
if( klients->z( i ) == zKlient )
|
|
if( klients->z( i ) == zKlient )
|
|
{
|
|
{
|
|
klients->remove( i );
|
|
klients->remove( i );
|
|
- klientAnzahl--;
|
|
|
|
gefunden = 1;
|
|
gefunden = 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -268,7 +263,7 @@ ASDatenbank *AnmeldungServer::zDB() const
|
|
|
|
|
|
bool AnmeldungServer::hatClients() const
|
|
bool AnmeldungServer::hatClients() const
|
|
{
|
|
{
|
|
- return klientAnzahl > 0;
|
|
|
|
|
|
+ return klients->hat(0);
|
|
}
|
|
}
|
|
|
|
|
|
int AnmeldungServer::getId() const
|
|
int AnmeldungServer::getId() const
|