Client.h 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "../global.h"
  3. #include <boost/thread.hpp>
  4. struct StartInfo;
  5. class CGameState;
  6. class CGameInterface;
  7. class CConnection;
  8. class CCallback;
  9. namespace boost
  10. {
  11. class mutex;
  12. class condition_variable;
  13. }
  14. template <typename T>
  15. struct CSharedCond
  16. {
  17. boost::mutex *mx;
  18. boost::condition_variable *cv;
  19. T *res;
  20. CSharedCond(T*R)
  21. {
  22. res = R;
  23. mx = new boost::mutex;
  24. cv = new boost::condition_variable;
  25. }
  26. ~CSharedCond()
  27. {
  28. delete res;
  29. delete mx;
  30. delete cv;
  31. }
  32. };
  33. class CClient
  34. {
  35. CCallback *cb;
  36. CGameState *gs;
  37. std::map<ui8,CGameInterface *> playerint;
  38. CConnection *serv;
  39. void waitForMoveAndSend(int color);
  40. public:
  41. CClient(void);
  42. CClient(CConnection *con, StartInfo *si);
  43. ~CClient(void);
  44. void close();
  45. void process(int what);
  46. void run();
  47. friend class CCallback;
  48. friend class CScriptCallback;
  49. };