📄 mysocket.cpp
字号:
// MySocket.cpp : implementation file
//
#include "..\stdafx.h"
//#include "DRPointManger.h"
#include "MySocket.h"
#include "PointDatastruct.h"
#include "../Async/Async.h"
#include "Abstractsock.h"
//#include "UsingSocket.h"
#include "../MyLog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMySocket
CMySocket::CMySocket(DWORD a)
{
outputWnd=NULL;
myReadQ = new PacketQ;
myWriteQ = new PacketQ;
ReadOffset=0;
WriteOffset=0;
m_hSocket = (DWORD)g_pConnection->GetSocket();
}
CMySocket::CMySocket()
{
outputWnd=NULL;
myReadQ = new PacketQ;
myWriteQ = new PacketQ;
ReadOffset=0;
WriteOffset=0;
m_hSocket = (DWORD)g_pConnection->GetSocket();
}
CMySocket::~CMySocket()
{
//Msg("close socket");
delete myReadQ;
delete myWriteQ;
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CMySocket, CSocket)
//{{AFX_MSG_MAP(CMySocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CMySocket member functions
void CMySocket::OnAccept(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
// CSocket::OnAccept(nErrorCode);
// ((CAbstractSock *)parent)->MyAccept(this);
}
void CMySocket::OnConnect(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
// CSocket::OnConnect(nErrorCode);
//DebugPrintf("Client Connected ");
//((CGSession *)parent)->MyConnect(this);
}
void CMySocket::OnClose(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
// CSocket::OnClose(nErrorCode);
DebugPrintf("硈絬闽超");
//((CGSession *)parent)->MyClose(this);
}
void CMySocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
// CSocket::OnReceive(nErrorCode);
int iRet = Read();
if ( iRet > 0 )
{
DebugPrintf("Read something,parent=%d",parent);
if( iRet > 1 )
{
_asm nop;
}
for( int i = 0 ; i < iRet ; i ++)
((CAbstractSock *)parent)->MyRead(this);
DebugPrintf("Send to gameClient Success");
}
else if( iRet == 0 )
{
DebugPrintf("Read nothing");
return;
}
else
{
// ((CAbstractSock *)parent)->MyError(this);
DebugPrintf("Network Error: 礚猭弄
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -