Пример #1
0
// Text in a Package is arrived. 
void MyIOCP::Packagetext(CIOCPBuffer *pOverlapBuff,int nSize,ClientContext *pContext)
{
	CString txt="";
	BYTE type;
	if(pOverlapBuff->GetPackageInfo(type,txt))
	{
		// to be sure that pcontext Suddenly does not dissapear by disconnection... 
		m_ContextMapLock.Lock();
		pContext->m_ContextLock.Lock();
		pContext->m_sReceived=txt;
		// Update that we have data
		pContext->m_iNumberOfReceivedMsg++;
		pContext->m_bUpdate=TRUE;
		pContext->m_ContextLock.Unlock();
		m_ContextMapLock.Unlock();

		// Update Statistics. 
		m_StatusLock.Lock();
		m_iNumberOfMsg++;
		m_StatusLock.Unlock();
		// Send back the message if we are echoing. 
		// Send Flood if needed. 
		BOOL bRet=FALSE;
		if(m_bFlood)
			bRet=BuildPackageAndSend(pContext,m_sSendText);
		

	}
}
Пример #2
0
// Text in a Package is arrived. 
void MyIOCP::Packagetext(CIOCPBuffer *pOverlapBuff,int nSize,CIOCPContext *pContext)
{
	CString txt="";
	BYTE type;
	if(pOverlapBuff->GetPackageInfo(type,txt))
	{
		// to be sure that pcontext Suddenly does not dissapear by disconnection... 
		m_ContextMapLock.Lock();
		pContext->m_ContextLock.Lock();
		pContext->m_sReceived=txt;
		// Update that we have data
		pContext->m_iNumberOfReceivedMsg++;
		pContext->m_ContextLock.Unlock();
		m_ContextMapLock.Unlock();

		// Update Statistics. 
		m_StatusLock.Lock();
		m_iNumberOfMsg++;
		m_StatusLock.Unlock();
		// Log
		AppendLog(txt);
		SendMessage(m_hWnd, WM_INCOMING_MESSAGE, (WPARAM)pContext->m_Socket, (LPARAM)(LPCTSTR)txt);

		// Send back the message if we are echoing. 
		// Send Flood if needed. 
		BOOL bRet=FALSE;
		if(m_bFlood)
			bRet=BuildPackageAndSend(pContext,m_sSendText);
	}
}
Пример #3
0
BOOL MyIOCP::BuildPackageAndSend(int ClientID, CString sText)
{
	BOOL bRet=FALSE;
	m_ContextMapLock.Lock();
	ClientContext* pContext = FindClient(ClientID);

	if (pContext == NULL)
		return FALSE;
	bRet=BuildPackageAndSend(pContext,sText);
	m_ContextMapLock.Unlock();
	return bRet;
}