⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btpeer.h

📁 模拟P2P各种网络环境的,适合新手们的学习,不错的源码.
💻 H
字号:
#ifndef __BTPEER_H__
#define __BTPEER_H__
#include <map>
#include<string>
#include <iostream>
#include "Agent.h"
#include "BTDocument.h"
class BTSession;
class BTEvent;
class BTTracker;
class Cache;
using namespace std;

typedef enum{
	work=0,
	retire
}peerState;

typedef enum{
	normal = 0,
	superseed
}peerType;

class BTPeer: public Agent{

public:
	unsigned int 	MaxConnectionNum;
	
	map<string, BTSession*>	mSessions;
	map<string, BTDocument*>	mDocuments;
	peerType 	mType;
	Cache*		mCache;
	peerState 	mState;
	double		mStartTime;
	unsigned int 	mConnectionNum;
	
public:
	BTPeer(peerType);
	~BTPeer(void);
	BTSession* getSession(string key);
	BTSession* addSession(string key);
	void removeSession(BTSession* session);
	BTDocument* getDocument(string key);
	BTDocument* addDocument(string key, int size, int popularity);
	void ownDocument(BTDocument* doc);
	void publish(string, BTTracker*);
	void handler(SimEvent*);
	void handleRanDomDownloadFile(BTEvent*);
	void handlePublishFile(BTEvent*);
	void handlePeerMessage(BTEvent*);
	void handleHandShake(BTEvent*);
	void handleESPRecover( BTEvent* );
	void handleESPRetire( BTEvent* );
	void printDownloadInfo(void);
	unsigned int getConNum(void){
		return mConnectionNum;
	};
	unsigned int getActiveSessionNum(void);
	void setStateWork(void){
		mState = work;
	}
	bool ifUpload(void);
	unsigned int getAvalConNum( void );
	unsigned int getSessionActConNum( string );
	string toString(void);
	
};
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -