⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connect.h

📁 简单聊天室服务器源码
💻 H
字号:
#if !defined(AFX_CONNECT_H__6EEED8D0_B1FF_11D3_97CA_0080C8EC42B6__INCLUDED_)
#define AFX_CONNECT_H__6EEED8D0_B1FF_11D3_97CA_0080C8EC42B6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Connect.h : header file
//

//struct TALKGUEST
//{
//	unsigned char szName[21];
//	DWORD dwIndex;
//};
#include "NetMsg.h"

/////////////////////////////////////////////////////////////////////////////
// CConnect command target

class CConnect : public CAsyncSocket
{
// Attributes
public:

// Operations
public:
	CConnect(CWnd *pWnd);
	virtual ~CConnect();

// Overrides
public:
//	TALKGUEST m_guest,m_Object;
	CString			str;
	CString			m_strBuf;
	CString			m_strName;
//	LPBYTE			m_lpBuf;
	BOOL			m_bData;
	CWnd			*m_pWnd;
	CConnect		*m_pPrev,	*m_pNext;
	DWORD			m_Msg[3];

	CString& GetGuestName()
	{
		return m_strName;
	}
	
	CString& GetObjectName()
	{
		str=m_strBuf.Left(m_strBuf.Find('\n'));
		return str;
	}

	CString& GetSourceName()
	{
		int i,j;
		i=m_strBuf.Find('\n')+1;
		j=m_strBuf.Find('\n',i)-i;
		str=m_strBuf.Mid(i,j);
		return str;
	}
	
	CString& GetTopic()
	{
		int i;
		i=m_strBuf.GetLength()-m_strBuf.ReverseFind('\n')-1;
		str=m_strBuf.Right(i);
		return str;
	}

	DWORD GetPicture()	//此函数必须在消息是NET_GUEST时调用
	{
		if(m_Msg[0]==NET_GUEST) return m_Msg[2];
		return 0;
	}

	DWORD GetBufLength()
	{
		return m_Msg[1];
	}

	BOOL IsPublic() //此函数必须在消息是NET_DATA时调用
	{
		if(m_Msg[2])return TRUE;
		return FALSE;
	}

	void SendMsg(DWORD dwMsg1,DWORD dwMsg2,DWORD dwMsg3)
	{
		m_Msg[0]=dwMsg1;
		m_Msg[1]=dwMsg2;
		m_Msg[2]=dwMsg3;
		int IRC=Send(&m_Msg,12);
	}

	void SendData(DWORD dwMsg, DWORD dwLength,
						DWORD dwAddtion, CString &strBuf)
	{
		SendMsg(dwMsg,dwLength,dwAddtion);
		int IRC=Send(strBuf.GetBuffer(dwLength),dwLength);
		strBuf.ReleaseBuffer();
	}

	CString& GetBuf()
	{
		return m_strBuf;
	}
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CConnect)
	public:
	virtual void OnReceive(int nErrorCode);
	virtual void OnClose(int nErrorCode);
	//}}AFX_VIRTUAL

	// Generated message map functions
	//{{AFX_MSG(CConnect)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG

// Implementation
protected:
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CONNECT_H__6EEED8D0_B1FF_11D3_97CA_0080C8EC42B6__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -