NewsServer.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 id;
  23. bool nichtPausiert;
  24. int empfangen;
  25. int gesendet;
  26. bool end;
  27. public:
  28. // Konstruktor
  29. NewsServer(InitDatei* zIni);
  30. // Destruktor
  31. virtual ~NewsServer();
  32. // nicht constant
  33. void runn();
  34. void thread();
  35. void close();
  36. bool serverStarten();
  37. bool serverPause();
  38. bool serverFortsetzen();
  39. bool serverBeenden();
  40. bool setMaxKlients(int mc);
  41. bool absturzKlient(int klientId);
  42. bool removeKlient(NSKlient* zKlient);
  43. void addGesendet(int bytes);
  44. void addEmpfangen(int bytes);
  45. // conatant
  46. bool istAn() const;
  47. Server* zServer() const;
  48. NSDatenbank* zDB() const;
  49. bool hatClients() const;
  50. int getId() const;
  51. const char* getLetzterFehler() const;
  52. };
  53. class NSAKlient : public Thread
  54. {
  55. private:
  56. SSLSKlient* klient;
  57. Text* name;
  58. Text* passwort;
  59. int adminId;
  60. NewsServer* ns;
  61. public:
  62. // Konstruktor
  63. NSAKlient(SSLSKlient* klient, NewsServer* ns);
  64. // Destruktor
  65. virtual ~NSAKlient();
  66. // nicht constant
  67. void thread();
  68. void errorZuKlient(const char* nachricht) const; // sendet eine Fehlernachricht zum AKlient
  69. };
  70. class NSKlient : public Thread
  71. {
  72. private:
  73. SKlient* klient;
  74. unsigned int klientNummer;
  75. NewsServer* ns;
  76. public:
  77. // Konstruktor
  78. NSKlient(SKlient* klient, NewsServer* ns);
  79. // Destruktor
  80. virtual ~NSKlient();
  81. // nicht constant
  82. void absturz();
  83. void thread();
  84. // constant
  85. void errorZuKlient(const char* nachricht) const; // sendet eine Fehlernachricht zum Klient
  86. int getKlientNummer() const;
  87. };
  88. #endif