HP-Socket/Windows/Demo/TestEcho-PFM/Server/ServerDlg.h
2021-08-12 21:50:04 +08:00

69 lines
1.9 KiB
C++

// ServerDlg.h : header file
//
#pragma once
#include "afxwin.h"
#include "../../../Include/HPSocket/HPSocket.h"
#include "../../Global/helper.h"
// CServerDlg dialog
class CServerDlg : public CDialogEx, public CTcpServerListener
{
// 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 OnClose();
DECLARE_MESSAGE_MAP()
public:
void SetAppState(EnAppState state);
void Statistics();
void Reset(BOOL bResetClientCount = TRUE);
private:
virtual EnHandleResult OnPrepareListen(ITcpServer* pSender, SOCKET soListen);
virtual EnHandleResult OnSend(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength);
virtual EnHandleResult OnReceive(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength);
virtual EnHandleResult OnClose(ITcpServer* pSender, CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
virtual EnHandleResult OnAccept(ITcpServer* pSender, CONNID dwConnID, UINT_PTR soClient);
virtual EnHandleResult OnShutdown(ITcpServer* pSender);
private:
CListBox m_Info;
CEdit m_Port;
CComboBox m_SendPolicy;
CComboBox m_ThreadCount;
CComboBox m_MaxConnCount;
CButton m_Start;
CButton m_Stop;
EnAppState m_enState;
volatile LONGLONG m_llTotalReceived;
volatile LONGLONG m_llTotalSent;
volatile LONG m_lClientCount;
CCriSec m_cs;
CTcpServerPtr m_Server;
};