Rerequester.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- // Rerequester.h: interface for the CRerequester class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_REREQUESTER_H__79411383_1CEA_45EC_92A2_D1B53A363000__INCLUDED_)
- #define AFX_REREQUESTER_H__79411383_1CEA_45EC_92A2_D1B53A363000__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include <afxinet.h>
- #include "memstream.h"
- #include "Encrypter.h"
- class CConnector;
- class CStorageWrapper;
- class CMeasure;
- class CDownloaderFeedback;
- #define REQ_STARTED 0
- #define REQ_COMPLETED 1
- #define REQ_STOPPED 2
- #define REQ_QUERY 3
- class CRerequesterSingle
- {
- public:
- CRerequesterSingle();
- ~CRerequesterSingle();
- bool OpenUrlEx(string strUrl, HANDLE hHttpDone, long lEvent);
- int GetResult(string& strErr);
- void WaitTerminate();
- memstream m_RetStream;
- long m_lEvent;
- private:
- static DWORD WINAPI SendRequestProc(void *pParam);
- void SendRequest();
- void OpenUrl(string strUrl, memstream& buf);
- HANDLE m_hHttpDone;
- HANDLE m_hDone;
- CInternetSession m_session;
- string m_strUrl;
- bool m_iResult;
- string m_strErr;
- };
- class CRerequester
- {
- public:
- CRerequester(long lConnectErrorMax, long lConnectIntval, long minpeers, long maxpeers);
- void Create(CDownloaderFeedback* pMain,CStorageWrapper* pStorageWrapper, CMeasure* pupmeasure, CMeasure* pdownmeasure,
- CConnector* pConnector, CEncrypter* pEncrypter, string strUrl, long port, string strIP,
- char* pMyId, char* pInfoHash, long interval,
- long lTimeOut, HANDLE hevDone);
- virtual ~CRerequester();
- void SetConnectErrorMax(long lConnectErrorMax, long lConnectIntval, long minpeers, long maxpeers);
- void AnnounceEx(long lEvent = REQ_QUERY);
- void PostExcute();
- void Excute();
- void Close();
- HANDLE GetHttpEvent();
- private:
- void announce(long lEvent = REQ_QUERY);
- bool postrequest();
- CDownloaderFeedback* m_pMain;
- CStorageWrapper* m_pStorageWrapper;
- CMeasure* m_pupmeasure;
- CMeasure* m_pdownmeasure;
- CConnector* m_pConnector;
- CEncrypter* m_pEncrypter;
- string m_strUrl;
- long m_minpeers;
- long m_maxpeers;
- long m_lTimeOut;
- HANDLE m_hevDone;
- long m_lAannounce_interval;
- long m_lInterval;
- string m_strTrackerid;
- long m_lLast;
- long m_lFileCount;
- long m_lConnectErrorMax;
- long m_lConnectIntval;
- HANDLE m_hHttpDone;
- time_t m_tLast;
- time_t m_tStartLast;
- bool m_never_succeeded;
- bool m_bStarted;
- vector<long> m_commands;
- bool m_bCommand;
- vector<CRerequesterSingle*> m_vSingles;
- CRerequesterSingle* m_pSingle;
- };
- #endif // !defined(AFX_REREQUESTER_H__79411383_1CEA_45EC_92A2_D1B53A363000__INCLUDED_)