1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #pragma once
- #include <unordered_map>
- #include <memory>
- #include <shared_mutex>
- #include <mutex>
- #include "../Protocol/win/Protocol.pb.h"
- #include "../common/comm.h"
- class CUserSocket;
- class CIOBuffer;
- struct Robot
- {
- int32_t uid;
-
- int32_t type;
- std::string name;
- RemoNet::UserState state;
- CarType car;
- };
- class CUserManager
- {
- public:
- void Add(CUserSocket* ptr);
- void Check(int32_t uid);
- void Remove(CUserSocket* lhs);
- void Write(int32_t id, CIOBuffer* pBuffer);
- RemoNet::UserState GetState(int32_t uid);
-
- static CUserManager& GetInstance();
- RemoNet::VideoDesc ConnectPeerVideo(int32_t peer, int32_t uid, int32_t index);
- void NotifyOffer(int32_t peer, int32_t uid, int32_t video, const char* type, const char* sdp);
- void NotifyAnswer(int32_t peer, int32_t uid, int32_t video, const char* type, const char* sdp);
- 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);
- void ReplyPeerVideo(int32_t peer, int32_t uid, RemoNet::VideoDesc ret, int32_t index);
- void LeavePeerVideo(int32_t peer, int32_t uid, EgoType type);
- void ClosePeerVideo(int32_t peer, int32_t uid, EgoType type,int32_t index);
- void NotifyMoveBegin(int32_t peer, int32_t uid, WorkArea area, int32_t no);
- void NotifyMoveEnd(int32_t peer,int32_t uid, WorkArea, int32_t no);
- void GetRobot(std::vector<Robot>& ret);
- void BroadCast(CIOBuffer* pBuffer);
- void NotifyState(int32_t uid,EgoType type, RemoNet::UserState state );
- void NotifySwitchDriver(int32_t peer, int32_t uid);
- void NotifyMoveRet(int32_t peer, int32_t uid, RemoNet::MoveDesc desc);
- void Start();
- void Run();
- private:
- std::vector<CUserSocket*> SocketList;
-
- std::mutex _lock;
- std::thread _thread;
- bool _run;
- };
|