Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / MFC

Barry's Chat System

Rate me:
Please Sign up or sign in to vote.
4.91/5 (8 votes)
24 Nov 20025 min read 140.7K   7.5K   57  
Barry's Chat System
// ChatServerDoc.h : interface of the CChatServerDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_CHATSERVERDOC_H__E8E2AD0C_509F_11D6_9693_AF0E159D6826__INCLUDED_)
#define AFX_CHATSERVERDOC_H__E8E2AD0C_509F_11D6_9693_AF0E159D6826__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "lstnsock.h"
#include "clntsock.h"
#include "ConnectThread.h"

#include <afxmt.h>

class CMsg;


class CChatServerSrvrItem;

class CChatServerDoc : public COleServerDoc
{
protected: // create from serialization only
	CChatServerDoc();
	DECLARE_DYNCREATE(CChatServerDoc)

// Attributes
public:
	CChatServerSrvrItem* GetEmbeddedItem()
		{ return (CChatServerSrvrItem*)COleServerDoc::GetEmbeddedItem(); }

	CListeningSocket* m_pSocket;
	CStringList       m_msgList;
//	CStringList       m_chattersList;
	CPtrList          m_connectionList;

	BOOL 	          bIsNewChatter;

	CString           m_ChattersList;

// Operations
public:
	void UpdateClients(int nCode);
	void ProcessPendingAccept();
	void ProcessPendingRead(CClientSocket* pSocket);
	CMsg* AssembleMsg(CClientSocket* pSocket , int nCode);
	CMsg* ReadMsg(CClientSocket* pSocket);
	void SendMsg(CClientSocket* pSocket, CMsg* pMsg);
	void CloseSocket(CClientSocket* pSocket);
	void Message(LPCTSTR lpszMessage);
	BOOL DuplicateName(CString sName);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CChatServerDoc)
	protected:
	virtual COleServerItem* OnGetEmbeddedItem();
	public:
	virtual BOOL OnNewDocument();
	virtual void DeleteContents();
	virtual void Serialize(CArchive& ar);
	//}}AFX_VIRTUAL

// Implementation
public:
	void UpdateMessages();
	void UpdateConnections();
	void SendUpdatedList(CMsg* pMsg);
	void DeleteChatter(CMsg* pMsg);
	void UpdateChattersList(CString string , CClientSocket* pSocket);
	void UpdateChattersNames(CMsg* pMsg , CString sName);

	virtual ~CChatServerDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CChatServerDoc)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !

	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_CHATSERVERDOC_H__E8E2AD0C_509F_11D6_9693_AF0E159D6826__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
India India
Nothing to boast about

Comments and Discussions