📄 connect.cpp
字号:
// Connect.cpp : implementation file
//
#include "stdafx.h"
#include "TalkS.h"
#include "Connect.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CConnect
CConnect::CConnect(CWnd *pWnd)
{
m_pPrev=NULL;
m_pNext=NULL;
m_pWnd=pWnd;
m_bData=FALSE;
}
CConnect::~CConnect()
{
Close();
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CConnect, CAsyncSocket)
//{{AFX_MSG_MAP(CConnect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CConnect member functions
void CConnect::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here
if(m_bData)
{
Receive(m_strBuf.GetBuffer(m_Msg[1]),m_Msg[1]);
m_strBuf.ReleaseBuffer();
if(m_Msg[0]==NET_GUEST) m_strName=m_strBuf;
m_pWnd->SendMessage(WM_NETDATA,m_Msg[0],(LPARAM)this);
//由窗口响应函数调用GetBuf()或GetGuestName()
m_bData=FALSE;
}
else
{
Receive(m_Msg,12);
switch(m_Msg[0])
{
case NET_DATA:
case NET_GUEST: m_bData=TRUE;
break;
}
}
CAsyncSocket::OnReceive(nErrorCode);
}
void CConnect::OnClose(int nErrorCode)
{
// TODO: Add your specialized code here
//要确定是否是Guest的退出,还是Sever的强制关闭
//在WPARAM 中包含这一信息
m_pWnd->SendMessage(WM_NETDELETE,0,(LPARAM)this);
CAsyncSocket::OnClose(nErrorCode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -