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

📄 msnloginsocket.cpp

📁 VideoMan is a very easy image acquisition library. It is able to manage many video inputs at the sam
💻 CPP
字号:
// Client.cpp : implementation file
//

#include "stdafx.h"
#include "SimMsnMessenger.h"
#include "MsnLoginSocket.h"
#include "MsnLoginClient.h"

//#include "RecvDg.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMsnLoginSocket

CMsnLoginSocket::CMsnLoginSocket()
{
}


CMsnLoginSocket::CMsnLoginSocket(CMsnLoginClient* pClient)
{
	m_pClient = pClient;

	m_pFile = NULL;
	m_pArchiveIn = NULL;
	m_pArchiveOut = NULL;

}

CMsnLoginSocket::~CMsnLoginSocket()
{
	/*  ???  1998-07-24
	if( m_pFile != NULL )
	{
		delete m_pFile;
		m_pFile = NULL;
	}
	if( m_pArchiveIn != NULL)
	{
		delete m_pArchiveIn;
		m_pArchiveIn = NULL;
	}
	if( m_pArchiveOut != NULL)
	{
		delete m_pArchiveOut;
		m_pArchiveOut = NULL;
	}
	*/
	//delete m_pRecvDg;
}


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

/////////////////////////////////////////////////////////////////////////////
// CMsnLoginSocket member functions

int CMsnLoginSocket::Send(const void* lpBuf, int nBufLen, int nFlags) 
{
	// TODO: Add your specialized code here and/or call the base class
	FileLog("->发送%d字节:[%s]",  nBufLen , lpBuf);
	return CSocket::Send(lpBuf, nBufLen, nFlags);
}

void CMsnLoginSocket::OnReceive(int nErrorCode)
{
	char bufRecv[512];

	//char bufTem[512];
	int  iTem;
	int  iLen;
	int	 iStart, iEnd;
	char  cTem;
	CString strTem1,strTem2;
	int  i;

	do
	{
		iLen = this->Receive( bufRecv, 512 );
 		if (iLen >= 511 )
					iLen = 511;
		bufRecv[iLen] = 0x00;
		FileLog("<-接收%d字节:<br>[%s]",  iLen , bufRecv);
		//DataLog("%s",bufRecv);
		if(m_pClient != NULL)
		{
			//process the recved Message:
			iStart = iEnd = 0;
			cTem = bufRecv[0];
			iTem = strTem1.GetLength();
		
			strTem1 = CString(bufRecv);
			
			//Lstrim:
			for( i=0; i < iTem; i++)
			{
				if(strTem1[0] == ' ')
				{
					strTem1 = strTem1.Mid(1,iTem);
				}
				else
					break;
			}
			
			iTem = strTem1.GetLength();

			i = 0;
			for(;iEnd < iTem;)
			{
				iEnd   = strTem1.Find(_T("\r\n"));  //?? CR LF?
				if(iEnd == -1)
					iEnd = strTem1.GetLength();

				strTem2 = strTem1.Mid(0,iEnd);
			
				m_pClient->ParseRecvedStr(strTem2);
				
		 
				
				iTem = strTem1.GetLength();
				if(iEnd+2 >= iTem)		break;
				strTem1 = strTem1.Mid(iEnd+2,iTem);
				i++;
			}
		
		}

		
	
	}
	while(!this->m_pArchiveIn->IsBufferEmpty());
	
	CSocket::OnReceive(nErrorCode);
}


⌨️ 快捷键说明

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