MinigameServer.h 2.3 KB

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