ShopServer.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef ShopServer_H
  2. #define ShopServer_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 ShSKlient;
  13. class ShopServer : public Thread
  14. {
  15. private:
  16. Server *server;
  17. Server *aServer;
  18. InitDatei *ini;
  19. ShSDatenbank *db;
  20. CRITICAL_SECTION cs;
  21. RCArray< ShSKlient > *klients;
  22. Text *fehler;
  23. Updater *updater;
  24. int klientAnzahl;
  25. int id;
  26. bool nichtPausiert;
  27. int empfangen;
  28. int gesendet;
  29. bool end;
  30. int ref;
  31. public:
  32. // Konstruktor
  33. ShopServer( InitDatei *zIni );
  34. // Destruktor
  35. virtual ~ShopServer();
  36. // nicht constant
  37. void runn();
  38. void thread();
  39. void close();
  40. bool serverStarten();
  41. bool serverPause();
  42. bool serverFortsetzen();
  43. bool serverBeenden();
  44. bool setMaxKarten( int mk );
  45. bool absturzKlient( int klientId );
  46. bool removeKlient( ShSKlient *zKlient );
  47. void addGesendet( int bytes );
  48. void addEmpfangen( int bytes );
  49. // conatant
  50. bool istAn() const;
  51. Server *zServer() const;
  52. ShSDatenbank *zDB() const;
  53. InitDatei *zInit() const;
  54. bool hatClients() const;
  55. int getId() const;
  56. char *getLetzterFehler() const;
  57. // Reference Counting
  58. ShopServer *getThis();
  59. ShopServer *release();
  60. };
  61. class ShSAKlient : public Thread
  62. {
  63. private:
  64. SKlient *klient;
  65. Text *name;
  66. Text *passwort;
  67. int adminId;
  68. ShopServer *shs;
  69. public:
  70. // Konstruktor
  71. ShSAKlient( SKlient *klient, ShopServer *shs );
  72. // Destruktor
  73. virtual ~ShSAKlient();
  74. // nicht constant
  75. void thread();
  76. void errorZuKlient( const char *nachricht ) const; // sendet eine Fehlernachricht zum AKlient
  77. };
  78. class ShSKlient : public Thread
  79. {
  80. private:
  81. SKlient *klient;
  82. unsigned int klientNummer;
  83. ShopServer *shs;
  84. int ref;
  85. public:
  86. // Konstruktor
  87. ShSKlient( SKlient *klient, ShopServer *shs );
  88. // Destruktor
  89. virtual ~ShSKlient();
  90. // nicht constant
  91. void absturz();
  92. void thread();
  93. // constant
  94. void errorZuKlient( const char *nachricht ) const; // sendet eine Fehlernachricht zum Klient
  95. int getKlientNummer() const;
  96. // Reference Counting
  97. ShSKlient *getThis();
  98. ShSKlient *release();
  99. };
  100. #endif