Server.h 1.6 KB

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