www.gusucode.com > VC++ UDP实现的服务器与客户端的双端视频通讯-源码程序 > VC++ UDP实现的服务器与客户端的双端视频通讯-源码程序/code/VideoServer/CReceiveSock.cpp

    //Download by http://www.NewXing.com
// CReceiveSock.cpp : implementation file
//

#include "stdafx.h"
#include "VideoServer.h"
#include "CReceiveSock.h"
#include "Global.h"
#include "VideoReceive.h"

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

/////////////////////////////////////////////////////////////////////////////
// CReceiveSock

CReceiveSock::CReceiveSock()
{
}

CReceiveSock::~CReceiveSock()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CReceiveSock member functions

void CReceiveSock::Init(CVideoReceive *pVideoReceive)
{
	m_pVideoReceive=pVideoReceive;
}

void CReceiveSock::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CAsyncSocket::OnAccept(nErrorCode);
}

void CReceiveSock::OnReceive(int nErrorCode) 
{
	VIDEO_DATA VideoData;
	memset(&VideoData,0,sizeof(VIDEO_DATA));
	Receive(&VideoData,sizeof(VIDEO_DATA));
	m_pVideoReceive->DecompressFrame(&VideoData);
	
	
	CAsyncSocket::OnReceive(nErrorCode);
}