Server.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. Game* zGame() const;
  35. };
  36. class FCKlient : public Thread
  37. {
  38. private:
  39. SSLSKlient* klient;
  40. SKlient* background;
  41. SKlient* foreground;
  42. unsigned int accountId;
  43. FactoryCraftServer* ls;
  44. GameClient* zGameClient;
  45. NetworkReader* backgroundReader;
  46. NetworkReader* foregroundReader;
  47. NetworkWriter* backgroundWriter;
  48. NetworkWriter* foregroundWriter;
  49. char* authKey;
  50. int authKeyLen;
  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. int getAccountId() const;
  63. NetworkWriter* zBackgroundWriter() const;
  64. NetworkWriter* zForegroundWriter() const;
  65. bool matchAuthKey( char* key, int len ) const;
  66. };