gamesocket.cpp

来自「一个局域网的五子棋程序」· C++ 代码 · 共 89 行

CPP
89
字号
// GameSocket.cpp : implementation file
//

#include "stdafx.h"
#include "wuzi.h"
#include "GameSocket.h"
#include "wuziDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGameSocket

CGameSocket::CGameSocket()
{
	m_pdlg=NULL;
}

CGameSocket::~CGameSocket()
{
	m_pdlg=NULL;
}


// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CGameSocket, CAsyncSocket)
	//{{AFX_MSG_MAP(CGameSocket)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0

/////////////////////////////////////////////////////////////////////////////
// CGameSocket member functions

void CGameSocket::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(nErrorCode==0)
		m_pdlg->OnAccept();
	//CAsyncSocket::OnAccept(nErrorCode);
}

void CGameSocket::OnClose(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(nErrorCode==0)
	{
		AfxMessageBox("对方已断开连接");
		m_pdlg->OnClose();
	}
	//CAsyncSocket::OnClose(nErrorCode);
}

void CGameSocket::OnConnect(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(nErrorCode==0)
	{
		
		m_pdlg->IsConnect(true);
			
	}
	else
	{
		m_pdlg->IsConnect(false);
	}
       
	//CAsyncSocket::OnConnect(nErrorCode);
}

void CGameSocket::OnReceive(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(nErrorCode==0)
		m_pdlg->OnReceive();
	//CAsyncSocket::OnReceive(nErrorCode);
}



void CGameSocket::SetParent(CWuziDlg *pDlg)
{
m_pdlg=pDlg;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?