KartenServer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef KartenServer_H
  2. #define KartenServer_H
  3. #include <Server.h>
  4. #include <Thread.h>
  5. #include <Datei.h>
  6. #include <Text.h>
  7. #include <InitDatei.h>
  8. #include "Datenbank.h"
  9. #include "Updater.h"
  10. using namespace Framework;
  11. using namespace Network;
  12. class KSKlient;
  13. class KartenServer : public Thread
  14. {
  15. private:
  16. Server *server;
  17. Server *aServer;
  18. InitDatei *ini;
  19. KSDatenbank *db;
  20. CRITICAL_SECTION cs;
  21. RCArray< KSKlient > *klients;
  22. Text *fehler;
  23. Updater *updater;
  24. int updateKarte;
  25. int klientAnzahl;
  26. int id;
  27. bool nichtPausiert;
  28. int empfangen;
  29. int gesendet;
  30. bool end;
  31. int ref;
  32. public:
  33. // Konstruktor
  34. KartenServer( InitDatei *zIni );
  35. // Destruktor
  36. virtual ~KartenServer();
  37. // nicht constant
  38. void runn();
  39. void thread();
  40. void close();
  41. bool serverStarten();
  42. bool serverPause();
  43. bool serverFortsetzen();
  44. bool serverBeenden();
  45. bool setMaxKarten( int mk );
  46. bool absturzKlient( int klientId );
  47. bool removeKlient( KSKlient *zKlient );
  48. void addGesendet( int bytes );
  49. void addEmpfangen( int bytes );
  50. void karteUpdateStart( int karteId );
  51. void karteUpdateEnde();
  52. // conatant
  53. bool istAn() const;
  54. Server *zServer() const;
  55. KSDatenbank *zDB() const;
  56. InitDatei *zIni() const;
  57. bool hatClients() const;
  58. int getId() const;
  59. char *getLetzterFehler() const;
  60. bool wirdKarteGeupdatet( int id ) const;
  61. // Reference Counting
  62. KartenServer *getThis();
  63. KartenServer *release();
  64. };
  65. class KSAKlient : public Thread
  66. {
  67. private:
  68. SKlient *klient;
  69. Text *name;
  70. Text *passwort;
  71. int adminId;
  72. KartenServer *ks;
  73. public:
  74. // Konstruktor
  75. KSAKlient( SKlient *klient, KartenServer *ks );
  76. // Destruktor
  77. virtual ~KSAKlient();
  78. // nicht constant
  79. void thread();
  80. void errorZuKlient( const char *nachricht ) const; // sendet eine Fehlernachricht zum AKlient
  81. };
  82. class KSKlient : public Thread
  83. {
  84. private:
  85. SKlient *klient;
  86. unsigned int klientNummer;
  87. KartenServer *ks;
  88. int ref;
  89. void suchDateien( const char *pf, RCArray< Text > *zDL, const char *rem );
  90. public:
  91. // Konstruktor
  92. KSKlient( SKlient *klient, KartenServer *ks );
  93. // Destruktor
  94. virtual ~KSKlient();
  95. // nicht constant
  96. void absturz();
  97. void thread();
  98. // constant
  99. void errorZuKlient( const char *nachricht ) const; // sendet eine Fehlernachricht zum Klient
  100. int getKlientNummer() const;
  101. // Reference Counting
  102. KSKlient *getThis();
  103. KSKlient *release();
  104. };
  105. #endif