www.pudn.com > chat-dialog.rar > SocketMsg.cpp


// SocketMsg.cpp: implementation of the CSocketMsg class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "Client1_2.h" 
#include "SocketMsg.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CSocketMsg::CSocketMsg() 
{ 
//	IsNewClient=false; 
//	IsQuit=false; 
	SystemMsg=SM_SENDMESSAGE; 
} 
 
CSocketMsg::~CSocketMsg() 
{ 
 
} 
 
CString CSocketMsg::FormatMsg() 
{ 
	CString strRet; 
//	strRet+=(IsNewClient)?"1":"0"; 
//	strRet+=(IsQuit)?"1":"0"; 
	strRet+=SystemMsg; 
	strRet+=Time.GetLength(); 
	strRet+=Time; 
	strRet+=ClientID.GetLength(); 
	strRet+=ClientID; 
	strRet+=SendMsg.GetLength(); 
	strRet+=SendMsg; 
	return strRet; 
} 
void CSocketMsg::FormatSocketMsg(CString strForm) 
{ 
//	IsNewClient=(strForm.Left(1)=="1")?TRUE:FALSE; 
//	strForm.Delete(0); 
	 
//	IsQuit=(strForm.Left(1)=="1")?TRUE:FALSE; 
//	strForm.Delete(0); 
	SystemMsg=strForm[0]; 
	strForm.Delete(0); 
	 
	CString str=strForm.Left(1); 
	int Len=str[0]; 
	strForm.Delete(0); 
	Time=strForm.Left(Len); 
	strForm.Delete(0,Len); 
 
	str=strForm.Left(1); 
	Len=str[0]; 
	strForm.Delete(0); 
	ClientID=strForm.Left(Len); 
	strForm.Delete(0,Len); 
 
	str=strForm.Left(1); 
	Len=str[0]; 
	strForm.Delete(0); 
	SendMsg=strForm.Left(Len); 
 
}