?? clientsocket.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 + -