LocalServer.h
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- /*
- * Openmysee
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
- #ifndef __LOCALSERVER_H_
- #define __LOCALSERVER_H_
- #include "ChannelMgr.h"
- #include "ChaosUI.h"
- #include "MsgMgr.h"
- #define LOCALSERVERPORT 11668
- #define MAX_PENDING_SOCKET 255
- #define USE_NAT 0
- // { Declaration of CLocalServer
- //local server将处理WM_SENDTOLOCALSERVER消息 WM是消息case, LM待定
- #define CASE_THREAD_EXIT 4
- class CLocalServer
- {
- public:
- static CLocalServer *CreateInstance();
- static void DeleteInstance();
- private:
- long m_ThreadRef;
- public:
- // 对每一个使用了在主线程建立的窗口的线程, 都应该调用该函数进行注册,并在线程退出时发送WM_SENDTOLOCALSERVER消息,
- // case为CASE_THREAD_EXIT,以便系统能对窗口资源进行回收而不至于死锁
- void AddWndThreadRef()
- {
- m_ThreadRef++;
- }
- void FireExit();
- void HandleLocalSrvNotify(WPARAM wparam, LPARAM lparam);
- BOOL Run();
- void Stop();
- BOOL AddChannel(SOCKET sock);
- void DeleteChannel(CHANNELID ChannelID);
- UINT GetChannelNum();
- void GetChannelIDArray(CHANNELID *pChannelIDArray);
- void GetChannelMgrArray(CChannelMgr* pChannelMgrArray[]);
- CChannelMgr *GetChannelMgr(CHANNELID ChannelID);
- void UpdateLayer1Notify(WPARAM wparam, LPARAM lparam);
- // CChannelMgr *GetChannelMgr(HWND hWnd);
- CMsgMgr* GetMsgMgr();
- void UpdateNoChannelMsg();
- // friend class CChaosUI;
- protected:
- CLocalServer();
- CLocalServer(const CLocalServer&);
- virtual ~CLocalServer();
- CLocalServer &operator=(const CLocalServer&);
- #if USE_NAT
- BOOL InitNatProxy();
- BOOL ExitNatProxy();
- #endif
- BOOL InitNetWork();
- static DWORD WINAPI _ConnectProc(LPVOID lpParam);
- HANDLE m_hConncetThread;
- bool volatile m_bConnStop;
- private:
- typedef std::map<CHANNELID, CChannelMgr *> ChannelMap;
- static CLocalServer *m_pLocalServer;
- CCritSec m_MapCritSec;
- ChannelMap m_ChannelMap;
- UINT m_uChlCounter;
- // UINT m_uMsgNum;
- SOCKET m_ListenSocket;
- DWORD m_dwConnectThreadID;
- CMsgMgr m_MsgMgr;
- MSGID m_ErrMsgID;
- };
- // Declaration of CLocalServer }
- #endif