SDC C-Project CF Review 프로그램
LYW
2021-11-09 9ad2aa59da822e9d30c5e0cd677025fe6e12df95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#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