ServerDlg.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // ServerDlg.h : header file
  2. //
  3. #pragma once
  4. #include "afxwin.h"
  5. #include "../../../Src/HPSocket.h"
  6. #include "../../Global/helper.h"
  7. // CServerDlg dialog
  8. class CServerDlg : public CDialogEx, public CUdpServerListener
  9. {
  10. // Construction
  11. public:
  12. CServerDlg(CWnd* pParent = nullptr); // standard constructor
  13. // Dialog Data
  14. enum { IDD = IDD_SERVER_DIALOG };
  15. protected:
  16. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  17. virtual BOOL PreTranslateMessage(MSG* pMsg);
  18. // Implementation
  19. protected:
  20. HICON m_hIcon;
  21. // Generated message map functions
  22. virtual BOOL OnInitDialog();
  23. afx_msg void OnPaint();
  24. afx_msg HCURSOR OnQueryDragIcon();
  25. afx_msg void OnBnClickedStart();
  26. afx_msg void OnBnClickedStop();
  27. afx_msg void OnBnClickedStatistics();
  28. afx_msg LRESULT CServerDlg::OnUserInfoMsg(WPARAM wp, LPARAM lp);
  29. afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
  30. afx_msg void OnClose();
  31. DECLARE_MESSAGE_MAP()
  32. public:
  33. void SetAppState(EnAppState state);
  34. void Statistics();
  35. void Reset(BOOL bResetClientCount = TRUE);
  36. private:
  37. virtual EnHandleResult OnPrepareListen(SOCKET soListen);
  38. virtual EnHandleResult OnSend(CONNID dwConnID, const BYTE* pData, int iLength);
  39. virtual EnHandleResult OnReceive(CONNID dwConnID, const BYTE* pData, int iLength);
  40. virtual EnHandleResult OnClose(CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
  41. virtual EnHandleResult OnAccept(CONNID dwConnID, const SOCKADDR_IN* pSockAddr);
  42. virtual EnHandleResult OnShutdown();
  43. private:
  44. CListBox m_Info;
  45. CEdit m_Port;
  46. CComboBox m_SendPolicy;
  47. CComboBox m_MaxConnCount;
  48. CComboBox m_RecvCount;
  49. CButton m_Start;
  50. CButton m_Stop;
  51. CButton m_Statistics;
  52. EnAppState m_enState;
  53. volatile LONGLONG m_llTotalReceived;
  54. volatile LONGLONG m_llTotalSent;
  55. volatile LONG m_lClientCount;
  56. CCriSec m_cs;
  57. CUdpServerPtr m_Server;
  58. };