Server.h 1.7 KB

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