Server.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include <Server.h>
  3. #include <Thread.h>
  4. #include <Datei.h>
  5. #include <Text.h>
  6. #include <InitDatei.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. Game* game;
  21. int runningThreads;
  22. int id;
  23. public:
  24. // Konstruktor
  25. FactoryCraftServer( InitDatei* zIni );
  26. // Destruktor
  27. virtual ~FactoryCraftServer();
  28. // nicht constant
  29. void run();
  30. void close();
  31. bool absturzKlient( int accountId );
  32. bool removeKlient( FCKlient* zKlient );
  33. bool hatClients() const;
  34. int getUnencryptedPort() const;
  35. Game* zGame() const;
  36. };
  37. class FCKlient : public Thread
  38. {
  39. private:
  40. SSLSKlient* klient;
  41. SKlient* background;
  42. SKlient* foreground;
  43. unsigned int accountId;
  44. FactoryCraftServer* ls;
  45. GameClient* zGameClient;
  46. NetworkReader* backgroundReader;
  47. NetworkReader* foregroundReader;
  48. NetworkWriter* backgroundWriter;
  49. NetworkWriter* foregroundWriter;
  50. char* authKey;
  51. int authKeyLen;
  52. public:
  53. // Konstruktor
  54. FCKlient( SSLSKlient* klient, FactoryCraftServer* ls );
  55. // Destruktor
  56. virtual ~FCKlient();
  57. void setForegroundClient( SKlient* foreground );
  58. void setBackgroundClient( SKlient* background );
  59. // nicht constant
  60. void absturz();
  61. void thread();
  62. // constant
  63. int getAccountId() const;
  64. NetworkWriter* zBackgroundWriter() const;
  65. NetworkWriter* zForegroundWriter() const;
  66. bool matchAuthKey( char* key, int len ) const;
  67. };