NewsServer.h 2.0 KB

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