#pragma once #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #endif #include #include #include #include #include #include "../common/comm.h" #include "remote_notify.h" #include "../common/remote_def.h" class CIOBuffer; class SocketRemote { public: typedef void (SocketRemote::* FN)(int8_t* Data, int16_t Size); SocketRemote(IRemoteNotify* n); bool Start(const char* ip); void Run(); void Stop(); void Write(CIOBuffer* pBuffer); void WriteAddRobot(std::string& serial, std::string& name, std::string url, int32_t type, int32_t car); void WriteOffer(int32_t peer, int32_t index, const char* type, const char* sdp); void WriteAnswer(int32_t peer, int32_t index, const char* type, const char* sdp); void WriteCandidate(int32_t peer, int32_t index, const char* candidate, int32_t sdp_mline_index, const char* sdp_mid); void WriteVideoReq(int32_t peer, int32_t index); void WriteVideoRep(int32_t peer, remote::VideoDesc desc, int32_t index); void WriteKeepAlive(); private: void NetProcess(int16_t cmd, int8_t* Data, int16_t Size); void OnNotifyRep(int8_t* Data, int16_t Size); void OnNotifyAdd(int8_t* Data, int16_t Size); void OnNotifyDel(int8_t* Data, int16_t Size); void OnAdd(int8_t* Data, int16_t Size); void OnNotifyLeave(int8_t* Data, int16_t Size); void OnNotifyOffer(int8_t* Data, int16_t Size); void OnNotifyAnswer(int8_t* Data, int16_t Size); void OnNotifyCandidate(int8_t* Data, int16_t Size); void OnNotifyState(int8_t* Data, int16_t Size); void OnNotifyReq(int8_t* Data, int16_t Size); void OnRobotRep(int8_t* Data, int16_t Size); private: std::unordered_map FnMap; IRemoteNotify* _notify; SOCKET sockfd; std::thread _thread; bool _run; bool _connected; int32_t _uid; std::string _ip; };