www.pudn.com > ChatUseIOCP.rar > ChatClientSocket.h


#pragma once 
#include "ChatProtocol.h" 
 
 
class CChatSocket : 
	public ChatProtocol 
{ 
public: 
	CChatSocket(void); 
	~CChatSocket(void); 
 
protected: 
	void OnSendComplete();			/// Triggered when a send is completed 
	void HandleDisconnect();			/// Triggered when the server disconnectes us 
	void HandleConnect();				/// Triggered when we got a connection 
 
	void HandleError(int nErrorCode, const char* pszDescription); 
	virtual void HandleWriteLog(int nImportance, const char* pszGroup, const char* pszLogEntry); 
	void HandleSendComplete() {}; 
	 
	/// Get's called when we get a new packet. Since we dont handle any packets in here, we just send them to our parent window. 
	void HandlePacket(Packet* pInPacket); 
 
	HWND m_hWndParent; 
 
public: 
 
	void Connect(const char* pszServer); 
 
	/// Initialization. 
	void Init(HWND hWndParent); 
 
	/// Login on the chat server. 
	bool Login(const char* szUserName, const char* szPassword); 
 
	/// Targetprefix # = channel, else user. 
	bool SendMessage(const char* szFrom, const char* szTarget, const char* szMessage); 
 
	/// Fetch a list with all users. 
	bool GetUsers(); 
 
};