NewsServer.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. SSLServer *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. public:
  29. // Konstruktor
  30. NewsServer( InitDatei *zIni );
  31. // Destruktor
  32. virtual ~NewsServer();
  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( NSKlient *zKlient );
  44. void addGesendet( int bytes );
  45. void addEmpfangen( int bytes );
  46. // conatant
  47. bool istAn() const;
  48. Server *zServer() const;
  49. NSDatenbank *zDB() const;
  50. bool hatClients() const;
  51. int getId() const;
  52. char *getLetzterFehler() const;
  53. };
  54. class NSAKlient : public Thread
  55. {
  56. private:
  57. SSLSKlient *klient;
  58. Text *name;
  59. Text *passwort;
  60. int adminId;
  61. NewsServer *ns;
  62. public:
  63. // Konstruktor
  64. NSAKlient( SSLSKlient *klient, NewsServer *ns );
  65. // Destruktor
  66. virtual ~NSAKlient();
  67. // nicht constant
  68. void thread();
  69. void errorZuKlient( const char *nachricht ) const; // sendet eine Fehlernachricht zum AKlient
  70. };
  71. class NSKlient : public Thread
  72. {
  73. private:
  74. SKlient *klient;
  75. unsigned int klientNummer;
  76. NewsServer *ns;
  77. public:
  78. // Konstruktor
  79. NSKlient( SKlient *klient, NewsServer *ns );
  80. // Destruktor
  81. virtual ~NSKlient();
  82. // nicht constant
  83. void absturz();
  84. void thread();
  85. // constant
  86. void errorZuKlient( const char *nachricht ) const; // sendet eine Fehlernachricht zum Klient
  87. int getKlientNummer() const;
  88. };
  89. #endif