btpeer.h
来自「模拟P2P各种网络环境的,适合新手们的学习,不错的源码.」· C头文件 代码 · 共 68 行
H
68 行
#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 + =
减小字号Ctrl + -
显示快捷键?