123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- // ServerDlg.h : header file
- //
- #pragma once
- #include "afxwin.h"
- #include "../../../Src/HPSocket.h"
- #include "../../Global/helper.h"
- class CServerDlg;
- class CTcpServerListenerImpl : public CTcpServerListener
- {
- public:
- CTcpServerListenerImpl(CServerDlg* pDlg) : m_pDlg(pDlg)
- {
- }
- private:
- virtual EnHandleResult OnPrepareListen(SOCKET soListen);
- virtual EnHandleResult OnSend(CONNID dwConnID, const BYTE* pData, int iLength);
- virtual EnHandleResult OnReceive(CONNID dwConnID, const BYTE* pData, int iLength);
- virtual EnHandleResult OnClose(CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
- virtual EnHandleResult OnAccept(CONNID dwConnID, SOCKET soClient);
- virtual EnHandleResult OnShutdown();
- private:
- void DetachConnInfo(CONNID dwConnID);
- BOOL ParseRequestHeader(BYTE*& pData, int& iLength, BOOL& isHttps, CString& strAddr, USHORT& usPort);
- BOOL CheckIfHttp(const BYTE* pData, int iLength);
- public:
- CServerDlg* m_pDlg;
- };
- class CTcpAgentListenerImpl : public CTcpAgentListener
- {
- public:
- CTcpAgentListenerImpl(CServerDlg* pDlg) : m_pDlg(pDlg)
- {
- }
- private:
- virtual EnHandleResult OnSend(CONNID dwConnID, const BYTE* pData, int iLength);
- virtual EnHandleResult OnReceive(CONNID dwConnID, const BYTE* pData, int iLength);
- virtual EnHandleResult OnClose(CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
- virtual EnHandleResult OnConnect(CONNID dwConnID);
- virtual EnHandleResult OnShutdown();
- private:
- void DetachConnInfo(CONNID dwConnID);
- public:
- CServerDlg* m_pDlg;
- };
- // CServerDlg dialog
- class CServerDlg : public CDialogEx
- {
- // Construction
- public:
- CServerDlg(CWnd* pParent = nullptr); // standard constructor
- // Dialog Data
- enum { IDD = IDD_SERVER_DIALOG };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- // Implementation
- protected:
- HICON m_hIcon;
- // Generated message map functions
- virtual BOOL OnInitDialog();
- afx_msg void OnPaint();
- afx_msg HCURSOR OnQueryDragIcon();
- afx_msg void OnBnClickedStart();
- afx_msg void OnBnClickedStop();
- afx_msg LRESULT CServerDlg::OnUserInfoMsg(WPARAM wp, LPARAM lp);
- afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
- afx_msg void OnBnClickedOptions();
- afx_msg void OnClose();
- DECLARE_MESSAGE_MAP()
- public:
- void SetAppState(EnAppState state);
- private:
- CListBox m_Info;
- CEdit m_Port;
- CButton m_Start;
- CButton m_Stop;
- CButton m_Options;
- CButton m_ShowLog;
- EnAppState m_enState;
- public:
- smart_simple_ptr<CTcpServerListenerImpl> m_pServerListener;
- smart_simple_ptr<CTcpAgentListenerImpl> m_pAgentListener;
- CTcpServerPtr m_Server;
- CTcpAgentPtr m_Agent;
- BOOL m_bLog;
- };
|