user_manager.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <stdint.h>
  3. #include <thread>
  4. #include <mutex>
  5. #include "remote_def.h"
  6. #include "../common/comm.h"
  7. class CUserHandler;
  8. class CIOBuffer;
  9. struct Benchboard
  10. {
  11. int32_t uid;
  12. int32_t type;
  13. std::string name;
  14. UserState state;
  15. };
  16. class CUserManager
  17. {
  18. public:
  19. void Add(CUserHandler* ptr);
  20. void Check(int32_t uid);
  21. void Remove(CUserHandler* lhs);
  22. void Write(int32_t id, CIOBuffer* pBuffer);
  23. static CUserManager& GetInstance();
  24. remote::VideoDesc ConnectPeerVideo(int32_t peer, int32_t uid, int32_t index);
  25. void NotifyOffer(int32_t peer, int32_t uid, int32_t video, const char* type, const char* sdp);
  26. void NotifyAnswer(int32_t peer, int32_t uid, int32_t video, const char* type, const char* sdp);
  27. void NotifyCandidate(int32_t peer, int32_t uid, int32_t video, const char* type, const char* candidate, int32_t sdp_mline_index, const char* sdp_mid);
  28. void ReplyPeerVideo(int32_t peer, int32_t uid, remote::VideoDesc ret, int32_t index);
  29. void LeavePeerVideo(int32_t peer, int32_t uid, EgoType type);
  30. void ClosePeerVideo(int32_t peer, int32_t uid, EgoType type,int32_t index);
  31. void GetRobot(std::vector<Benchboard>& ret);
  32. void BroadCast(CIOBuffer* pBuffer);
  33. void NotifyState(int32_t uid,EgoType type, UserState state );
  34. void Start();
  35. void Run();
  36. private:
  37. std::vector<CUserHandler*> SocketList;
  38. std::mutex _lock;
  39. std::thread _thread;
  40. bool _run;
  41. };