1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #pragma once
- #ifdef WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif
- #endif
- #include <WS2tcpip.h>
- #include <WinSock2.h>
- #include <thread>
- #include <unordered_map>
- #include <functional>
- #include "../common/comm.h"
- #include "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 WriteSigin(EgoType type, std::string& account,std::string& pass,std::string& name);
- 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 WriteVideoLeave(int32_t peer);
- void WriteKeepAlive();
- void WriteUserList();
- 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 OnSigin(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<int16_t, FN> FnMap;
- IRemoteNotify* _notify;
- SOCKET sockfd;
- std::thread _thread;
- bool _run;
- bool _connected;
- int32_t _uid;
- std::string _ip;
- };
|