⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clientsocket.cpp

📁 超强的图形界面聊天软件.rar
💻 CPP
字号:
// ClientSocket.cpp : implementation file
//

#include "stdafx.h"
#include "pictalk.h"
#include "ClientSocket.h"
#include "net.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CClientSocket
CClientSocket::CClientSocket(CNet * pNet)
{
	m_pNet=pNet;
	m_pFile = NULL;
	m_pArchiveIn = NULL;
	m_pArchiveOut = NULL;
	m_ID=0;
}
CClientSocket::CClientSocket()
{
	m_pFile = NULL;
	m_pArchiveIn = NULL;
	m_pArchiveOut = NULL;
	m_ID=0;
}

CClientSocket::~CClientSocket()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CClientSocket member functions

void CClientSocket::OnReceive(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class

	m_pNet->FetchMsg(this);
	CSocket::OnReceive(nErrorCode);
}
void CClientSocket::Init()
{
	m_pFile = new CSocketFile(this);
	m_pArchiveIn = new CArchive(m_pFile,CArchive::load);
	m_pArchiveOut = new CArchive(m_pFile,CArchive::store);
}

void CClientSocket::CheckMsg(mpack &Msgpack)
{
	if(Msgpack.m_SenderID==0)
		AfxMessageBox("消息错误",MB_OK);
	switch(Msgpack.m_MsgID)
	{
	case MID_PUBLICMSG:
	case(MID_PRIMSG):
		if(m_pNet->m_bReady){
				m_pNet->m_pPictalkDlg->ShowMsg(Msgpack);
				m_pNet->SendMsg(Msgpack,this);
		}
		break;
	case MID_ADDUSER:
		if(m_ID){
			if(!m_pNet->m_bReady)
				m_Willcon.Add(Msgpack);
		}
		else{
			m_ID=Msgpack.m_ID;
		}
		m_pNet->m_pPictalkDlg->AddUser(Msgpack);
		if(m_pNet->m_bReady)
			m_pNet->SendMsg(Msgpack,this);
		break;
	case MID_USERID:
		if(!m_pNet->m_bReady){
			m_pNet->m_pPictalkDlg->GetID(Msgpack);
			m_pNet->ConBegin();
		}
		break;
	case MID_DELUSER:
		m_pNet->m_pPictalkDlg->DelUser(Msgpack);
		m_pNet->SendMsg(Msgpack,this);
		break;
	case MID_VISIT:
		m_pNet->m_pPictalkDlg->m_MapUser[Msgpack.m_SenderID]->m_Visit=0;
		if(m_pNet->m_bReady)
			m_pNet->SendMsg(Msgpack,this);
		break;
	default:
		break;
	}
}

⌨️ 快捷键说明

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