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 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. char* authKey;
  49. int authKeyLen;
  50. public:
  51. // Konstruktor
  52. FCKlient(SSLSKlient* klient, FactoryCraftServer* ls);
  53. // Destruktor
  54. virtual ~FCKlient();
  55. void setForegroundClient(SKlient* foreground);
  56. void setBackgroundClient(SKlient* background);
  57. // nicht constant
  58. void absturz();
  59. void thread();
  60. // constant
  61. int getAccountId() const;
  62. NetworkWriter* zBackgroundWriter() const;
  63. NetworkWriter* zForegroundWriter() const;
  64. bool matchAuthKey(char* key, int len) const;
  65. };