Connector.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:2k
源码类别:
P2P编程
开发平台:
Visual C++
- // Connector.h: interface for the CConnector class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_CONNECTOR_H__8E8443EF_9C62_41C9_947E_3AE7E12ABBC3__INCLUDED_)
- #define AFX_CONNECTOR_H__8E8443EF_9C62_41C9_947E_3AE7E12ABBC3__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- class CConnection;
- class CEncryptedConnection;
- class CDownloader;
- class CUploader;
- class CStorageWrapper;
- class CMeasure;
- class CChoker;
- class CAddrPort;
- class CConnector
- {
- public:
- CConnector(long lMaxUploadRate);
- virtual ~CConnector();
- void Create(CDownloader* pDownloader, CUploader* pUploader, CChoker* pchoker,
- long lNumPieces, CStorageWrapper* pStorage, CMeasure* pUpTotalMeasure );
- long how_many_connections();
- void connection_flushed(CEncryptedConnection* pEConnection);
- void connection_made(CEncryptedConnection* pEConnection);
- void connection_lost(CEncryptedConnection* pEConnection);
- void got_message(CEncryptedConnection* pEConnection, memstream& memMessage);
- void _update_upload_rate(long lAmount);
- bool IsRatecap();
- void uncap();
- void SetMaxUploadRate(long lMaxUploadRate);
- void PausePeer(CAddrPort addrPort, bool bPause = true);
- void ClosePeer(CAddrPort addrPort);
- void OnIdle();
- const CDownloader* const GetDownloader() const;
- const CMeasure* const GetUpTotalMeasure() const;
- vector<CConnection*> m_connections;
- private:
- void _OnIdle(vector<CAddrPort>& vToPause, vector<CAddrPort>& vToContinue, vector<CAddrPort>& vToClose);
- void check_endgame();
- // data
- CDownloader* m_pDownloader;
- CUploader* m_pUploader;
- CStorageWrapper* m_pStorage;
- CMeasure* m_pUpTotalMeasure;
- CChoker* m_pChoker;
- long m_lNumPieces;
- long m_lMaxUploadRate;
- bool m_bEndgame;
- bool m_bRateCapped;
- time_t m_tTimeUntilUncap;
- time_t m_tcap;
- vector<CAddrPort> m_vToPause;
- vector<CAddrPort> m_vToContinue;
- vector<CAddrPort> m_vToClose;
- CCriticalSection m_criticalSection;
- };
- #endif // !defined(AFX_CONNECTOR_H__8E8443EF_9C62_41C9_947E_3AE7E12ABBC3__INCLUDED_)