#pragma once
|
#include "device.h"
|
|
#define MVSOL_DEVICE_FOUND 34700
|
|
#define MVSOL_DEVICE_MANAGER_STATE (WM_USER+0x1001)
|
|
namespace mvsol {
|
|
class AFX_EXT_CLASS DeviceManagerUdp
|
{
|
friend class DeviceInfo;
|
|
public:
|
DeviceManagerUdp(HWND hwnd);
|
~DeviceManagerUdp();
|
|
enum DeviceManagerState
|
{
|
kSendingBegin = 0,
|
kSendingEnd,
|
};
|
|
class SocketData
|
{
|
public:
|
SocketData();
|
~SocketData();
|
|
std::string localip;
|
|
sockaddr_in local;
|
sockaddr_in remote;
|
|
SOCKET socket;
|
|
CWinThread* thread;
|
BOOL isstop;
|
|
PBYTE buffer;
|
INT buffersize;
|
|
void* pthis;
|
INT index;
|
|
BOOL isconnected;
|
};
|
|
//Operation
|
public:
|
BOOL Open();
|
BOOL Open(INT index);
|
void Close();
|
void Close(INT index);
|
|
void Send();
|
void Send(INT index);
|
|
void IpAddress(const DeviceInfo& device, DWORD ipaddress);
|
void SetID(const DeviceInfo&device, uint64_t id);
|
|
protected:
|
void Init();
|
INT Encrypt(const PBYTE indata, const INT indatasize, PBYTE outdata, PINT outdatasize);
|
INT Decrypt(const PBYTE indata, const INT indatasize, PBYTE outdata, PINT outdatasize);
|
|
void StartReceiveThread();
|
void StartReceiveThread(INT index);
|
void StopReceiveThread();
|
void StopReceiveThread(INT index);
|
void OnThreadReceive(INT index);
|
static UINT ThreadReceiveFunc(LPVOID param);
|
|
void StartSendThread();
|
void StopSendThread();
|
void OnThreadSend();
|
static UINT ThreadSendFunc(LPVOID param);
|
|
protected:
|
virtual int Parse(INT index, const PBYTE indata, INT indatasize);
|
virtual int OnReceivePacket(INT index, const PBYTE indata, INT indatasize);
|
|
//Attribution
|
public:
|
|
|
protected:
|
SocketData* socketdata_;
|
INT socketdatasize_;
|
|
WSAData wsadata_;
|
|
HWND parenthandle_;
|
|
CWinThread* thread_;
|
BOOL isstop_;
|
|
};
|
|
|
} // namespace mvsol
|