Server.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 absturzKlient(int accountId);
  31. bool removeKlient(FCKlient* zKlient);
  32. bool hatClients() const;
  33. int getUnencryptedPort() const;
  34. };
  35. class FCKlient : public Thread
  36. {
  37. private:
  38. SSLSKlient* klient;
  39. SKlient* background;
  40. SKlient* foreground;
  41. unsigned int accountId;
  42. FactoryCraftServer* ls;
  43. GameClient* zGameClient;
  44. NetworkReader* backgroundReader;
  45. NetworkReader* foregroundReader;
  46. NetworkWriter* backgroundWriter;
  47. NetworkWriter* foregroundWriter;
  48. Critical cs;
  49. bool backgroundRunning;
  50. bool foregroundRunning;
  51. char* authKey;
  52. int authKeyLen;
  53. public:
  54. // Konstruktor
  55. FCKlient(SSLSKlient* klient, FactoryCraftServer* ls);
  56. // Destruktor
  57. virtual ~FCKlient();
  58. void setForegroundClient(SKlient* foreground);
  59. void setBackgroundClient(SKlient* background);
  60. // nicht constant
  61. void absturz();
  62. void thread();
  63. // constant
  64. int getAccountId() const;
  65. NetworkWriter* zBackgroundWriter() const;
  66. NetworkWriter* zForegroundWriter() const;
  67. bool matchAuthKey(char* key, int len) const;
  68. };