123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #ifndef SpielServer_H
- #define SpielServer_H
- #include <Server.h>
- #include <Thread.h>
- #include <Datei.h>
- #include <Text.h>
- #include "SSKlientV.h"
- #include <InitDatei.h>
- #ifdef WIN32
- #include "SpielErstellt/SpielErstellt.h"
- #include "Spiel/Spiel.h"
- #include "../Datenbank/Datenbank.h"
- #include "Historie/HistorieSender.h"
- #else
- #include "SpielErstellt.h"
- #include "Spiel.h"
- #include "Datenbank.h"
- #include "HistorieSender.h"
- #endif
- using namespace Framework;
- using namespace Network;
- class SSKlient;
- class SpielServer : public Thread
- {
- private:
- HistorieSender* historieS;
- Server* server;
- SSLServer* aServer;
- InitDatei* ini;
- SSDatenbank* db;
- CRITICAL_SECTION cs;
- SpielFinden* startSpielThread;
- RCArray< SpielErstellt >* erstellt;
- RCArray< Spiel >* spiele;
- RCArray< SSKlient >* klients;
- Array< int >* spielHistorieId;
- Text* fehler;
- int id;
- bool nichtPausiert;
- int empfangen;
- int gesendet;
- bool end;
- public:
- // Konstruktor
- SpielServer(InitDatei* zIni);
- // Destruktor
- virtual ~SpielServer();
- // nicht constant
- void lock();
- void unlock();
- void runn();
- virtual void thread();
- void close();
- bool serverStarten();
- bool serverPause();
- bool serverFortsetzen();
- bool serverBeenden();
- bool setMaxSpiele(int ms);
- void addSpielErstellt(SpielErstellt* erstellt);
- void SpielErstelltAbbruch(int spielErstelltId);
- void removeSpielErstellt(int id);
- bool registerKlient(SSKlient* klient);
- bool absturzKlient(int klientId);
- bool verteileKlient(SSKlient* klient);
- void unregisterKlient(SSKlient* zKlient);
- void klientsMM(SSKlient* k);
- void addSpiel(Spiel* spiel);
- void removeSpiel(int spielId);
- void addGesendet(int bytes);
- void addEmpfangen(int bytes);
- void addSpielHistorieId(int id);
- bool hatSpielHistorieId(int id);
- void removeSpielHistorieId(int id);
- // conatant
- bool istAn() const;
- Server* zServer() const;
- SSDatenbank* zDB() const;
- InitDatei* zInit() const;
- bool hatClients() const;
- int getId() const;
- const char* getLetzterFehler() const;
- const char* getIp() const;
- int getPort() const;
- };
- class SSAKlient : public Thread
- {
- private:
- SSLSKlient* klient;
- Text* name;
- Text* passwort;
- int adminId;
- SpielServer* ss;
- int version;
- public:
- // Konstruktor
- SSAKlient(SSLSKlient* klient, SpielServer* ss);
- // Destruktor
- virtual ~SSAKlient();
- // nicht constant
- void thread();
- void sendeVerzeichnisAnKlient(const char* pfad, int);
- void errorZuKlient(const char* nachricht) const; // sendet eine Fehlernachricht zum AKlient
- };
- class SSKlient : public SSKlientV
- {
- private:
- SKlient* empfangen;
- SKlient* senden;
- unsigned int klientNummer;
- SpielServer* ss;
- int accountId;
- bool termThread;
- bool verbunden;
- SpielErstellt* zErstellt;
- Spiel* zSpiel;
- CRITICAL_SECTION cs;
- public:
- // Konstruktor
- SSKlient(SKlient* klient, SpielServer* ss);
- // Destruktor
- virtual ~SSKlient() override;
- // nicht constant
- void lock();
- void unlock();
- void absturz();
- void setSpielErstellt(SpielErstellt* zErstellt);
- void setSpiel(Spiel* zSpiel);
- virtual void nichtTrennen() override;
- void spielGefunden(int karteId);
- void zeitVerbleibend(char sekunden);
- void erstellungAbgebrochen(const char* grund);
- void backInWarteschlange(char st, char min, char sec);
- void erstellungFortsetzen();
- void erstellungInitialisierung(SpielerTeamStruktur* sts);
- void erstellungAddSpieler(int accountId);
- void erstellungRemoveSpieler(int accountId);
- void erstellungSpielerTeam(int accountId, int spielerNummer);
- void erstellungChatNachricht(const char* nachricht);
- void spielLadenBeginn();
- void spielLadenSpielerAdd(int accId, int spielerNumer);
- void spielLadenSetSpielerProzent(int accId, int prozent);
- void spielLadenSetSpielerPing(int accId, int ping);
- virtual double ping() override;
- void spielLadenFertig();
- virtual void spielNachricht(short len, const char* bytes) override;
- virtual void statistikNachricht(short len, const char* bytes) override;
- bool keepAlive();
- virtual void trenne() override;
- void setSenden(SSKlient* klient);
- virtual void thread() override;
- virtual void errorZuKlientEmpfang(const char* nachricht) override; // sendet eine Fehlernachricht zum Klient
- virtual void errorZuKlientSende(const char* nachricht) override;
- // const
- virtual int getAccountId() const override;
- int getKlientNummer() const;
- SKlient* getKlient() const;
- };
- #endif
|