Server.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include <InitDatei.h>
  3. #ifdef _WINDOWS
  4. # include <Network\Server.h>
  5. #else
  6. # include <Server.h>
  7. #endif
  8. #include <Critical.h>
  9. #include <Text.h>
  10. #include <Thread.h>
  11. using namespace Framework;
  12. using namespace Network;
  13. class FCKlient;
  14. class GameClient;
  15. class FactoryCraftServer : virtual public ReferenceCounter
  16. {
  17. private:
  18. SSLServer* sslServer;
  19. Server* server;
  20. InitDatei* ini;
  21. Critical cs;
  22. RCArray<FCKlient>* klients;
  23. int runningThreads;
  24. int id;
  25. public:
  26. // Konstruktor
  27. FactoryCraftServer(InitDatei* zIni);
  28. // Destruktor
  29. virtual ~FactoryCraftServer();
  30. // nicht constant
  31. void run();
  32. void close();
  33. bool removeKlient(FCKlient* zKlient);
  34. bool hatClients() const;
  35. int getUnencryptedPort() const;
  36. };
  37. class FCKlient : public Thread
  38. {
  39. private:
  40. Network::SSLSKlient* klient;
  41. Network::SKlient* background;
  42. Network::SKlient* foreground;
  43. FactoryCraftServer* ls;
  44. GameClient* zGameClient;
  45. NetworkReader* backgroundReader;
  46. NetworkReader* foregroundReader;
  47. NetworkWriter* backgroundWriter;
  48. NetworkWriter* foregroundWriter;
  49. Critical cs;
  50. bool backgroundRunning;
  51. bool foregroundRunning;
  52. Framework::Text authKey;
  53. Framework::Text name;
  54. public:
  55. // Konstruktor
  56. FCKlient(Network::SSLSKlient* klient, FactoryCraftServer* ls);
  57. // Destruktor
  58. virtual ~FCKlient();
  59. void setForegroundClient(Network::SKlient* foreground);
  60. void setBackgroundClient(Network::SKlient* background);
  61. // nicht constant
  62. void absturz();
  63. void thread();
  64. // constant
  65. NetworkWriter* zBackgroundWriter() const;
  66. NetworkWriter* zForegroundWriter() const;
  67. bool matchAuthKey(char* key, int len) const;
  68. };