// ClientChat.cpp : implementation file
//

#include "stdafx.h"
#include "ChatServer.h"
#include "ClientChat.h"

#include "ChatServerDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CClientChat

CString ServerSystemStatus[];

CClientChat::CClientChat()
{
	IsLogin = false;
}

CClientChat::~CClientChat()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CClientChat member functions

void CClientChat::OnReceive(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
//***********************************************************************
	m_pdlg->ProcessRead( this );
//***********************************************************************
	
	CAsyncSocket::OnReceive(nErrorCode);
}


//****************************************************************************
CClientChat::CClientChat( CChatServerDlg* dlg )
{
	m_pdlg = dlg;
	IsLogin = false;
}

void CClientChat::Init()
{
//************************************************************************
	if ( !GetPeerName( IP_Addr, PortNumber ) )
		AfxMessageBox( "Can't get peer Name and Port when Accept." );
	else
	{
		char buffer[6];
		_itoa( PortNumber, buffer, 10 );
		CString temp = IP_Addr;
		temp += " ¥H ";
		temp += buffer;
		temp += "³s±µ." ;
		temp += '\n';
		m_pdlg->AddSysMsg( temp );

		this->Send( ServerSystemStatus[0] , ServerSystemStatus[0].GetLength() , 0 );
	}
//************************************************************************
}

void CClientChat::OnConnect(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
//*********************************************************

//*********************************************************
	CAsyncSocket::OnConnect(nErrorCode);
}
