00001 // 00002 // ChatCore.h 00003 // 00004 // Copyright (c) Shareaza Development Team, 2002-2005. 00005 // This file is part of SHAREAZA (www.shareaza.com) 00006 // 00007 // Shareaza is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 of 00010 // the License, or (at your option) any later version. 00011 // 00012 // Shareaza is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Shareaza; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 00022 #if !defined(AFX_CHATCORE_H__F550EC04_AC7C_42B1_BE5B_7CDF69EA2286__INCLUDED_) 00023 #define AFX_CHATCORE_H__F550EC04_AC7C_42B1_BE5B_7CDF69EA2286__INCLUDED_ 00024 00025 #pragma once 00026 00027 class CConnection; 00028 class CChatSession; 00029 00030 00031 class CChatCore 00032 { 00033 // Construction 00034 public: 00035 CChatCore(); 00036 virtual ~CChatCore(); 00037 00038 // Attributes 00039 public: 00040 CMutex m_pSection; 00041 protected: 00042 CPtrList m_pSessions; 00043 HANDLE m_hThread; 00044 BOOL m_bThread; 00045 CEvent m_pWakeup; 00046 00047 // Operations 00048 public: 00049 POSITION GetIterator() const; 00050 CChatSession* GetNext(POSITION& pos) const; 00051 int GetCount() const; 00052 BOOL Check(CChatSession* pSession) const; 00053 void Close(); 00054 void OnAccept(CConnection* pConnection, PROTOCOLID nProtocol = PROTOCOL_NULL); 00055 BOOL OnPush(GGUID* pGUID, CConnection* pConnection); 00056 void OnED2KMessage(CEDClient* pClient, CEDPacket* pPacket); 00057 CChatSession* FindSession(CEDClient* pClient); 00058 void StopThread(); 00059 protected: 00060 void Add(CChatSession* pSession); 00061 void Remove(CChatSession* pSession); 00062 void StartThread(); 00063 protected: 00064 static UINT ThreadStart(LPVOID pParam); 00065 void OnRun(); 00066 00067 friend class CChatSession; 00068 }; 00069 00070 extern CChatCore ChatCore; 00071 00072 #endif // !defined(AFX_CHATCORE_H__F550EC04_AC7C_42B1_BE5B_7CDF69EA2286__INCLUDED_)