Upload.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:2k
源码类别:
P2P编程
开发平台:
Visual C++
- // Upload.h: interface for the CUpload class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_UPLOAD_H__0488CF2F_D474_4738_9253_5BBA416475A1__INCLUDED_)
- #define AFX_UPLOAD_H__0488CF2F_D474_4738_9253_5BBA416475A1__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "Connection.h"
- #include "StorageWrapper.h"
- #include "Measure.h"
- #include "Choker.h"
- class CDownloaderFeedback;
- class CUpload
- {
- class CRequestsItem
- {
- public:
- CRequestsItem(long index, long begin, long length)
- {
- m_index = index;
- m_begin = begin;
- m_length = length;
- }
- long m_index;
- long m_begin;
- long m_length;
- };
- public:
- CUpload(CDownloaderFeedback* pDownloaderFeedback,
- CConnection* pconnection,
- CChoker* pchoker,
- CStorageWrapper* pstorage,
- long lMaxSliceLength,
- long lMaxRatePeriod,
- long lFudge);
- virtual ~CUpload();
- long get_rate();
- long get_total();
- bool has_queries();
- bool is_interested();
- bool is_choked();
- void unchoke();
- void choke();
- bool flushed();
- void got_cancel(long index, long begin, long length);
- void got_request(long index, long begin, long length);
- void got_interested();
- void got_not_interested();
- private:
- CConnection* m_pconnection;
- CStorageWrapper* m_pstorage;
- long m_lMaxSliceLength;
- long m_lMaxRatePeriod;
- bool m_bChoked;
- bool m_bInterested;
- vector <CRequestsItem> m_vBuffer;
- CMeasure m_Measure;
- // for feedback
- CDownloaderFeedback* m_pDownloaderFeedback;
- long m_lAddr;
- short m_sPort;
- };
- class CUploader
- {
- public :
- CUploader(CDownloaderFeedback* pDownloaderFeedback, CStorageWrapper* pstorage, CChoker* pchoker,long lMaxSliceLength, long lMaxRatePeriod, long lFudge);
- CUpload* make_upload(CConnection* pconnection);
- private:
- CChoker* m_pChoker;
- CStorageWrapper* m_pstorage;
- long m_lMaxSliceLength;
- long m_lMaxRatePeriod;
- long m_lFudge;
- // for feedback
- CDownloaderFeedback* m_pDownloaderFeedback;
- };
- #endif // !defined(AFX_UPLOAD_H__0488CF2F_D474_4738_9253_5BBA416475A1__INCLUDED_)