/// <summary> /// 构造函数 /// </summary> /// <param name="maxUploads">最大连接数量</param> /// <param name="scheduleFunction">计划函数</param> /// <param name="doneFlag">完成标志</param> public Choker(int maxUploads, SchedulerDelegate scheduleFunction, Flag doneFlag) { this.maxUploads = maxUploads; this.scheduleFunction = scheduleFunction; this.doneFlag = doneFlag; count = 0; connections = new List <IConnection>(); scheduleFunction(RoundRobin, 10, "Round Robin"); ran = new Random(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="connecter">连接管理类</param> /// <param name="rawServer">服务器类</param> /// <param name="myID">本地下载工具ID号</param> /// <param name="maxLength">最大请求子片断长度</param> /// <param name="scheduleFunction">计划函数</param> /// <param name="keepAliveDelay">发送keep alive信息的时间间隔</param> /// <param name="downloadID">对方下载工具ID号</param> /// <param name="maxInitiate">最大连接数</param> public Encrypter(IConnecter connecter, IRawServer rawServer, byte[] myID, int maxLength, SchedulerDelegate scheduleFunction, double keepAliveDelay, byte[] downloadID, int maxInitiate) { this.rawServer = rawServer; this.Connecter = connecter; this.MyID = myID; this.maxLength = maxLength; this.scheduleFunction = scheduleFunction; this.keepAliveDelay = keepAliveDelay; this.DownloadID = downloadID; this.maxInitiate = maxInitiate; this.connections = new Dictionary <ISingleSocket, IEncryptedConnection>(); scheduleFunction(SendKeepAlives, keepAliveDelay, "Send keep alives"); }
/// <summary> /// 构造函数 /// </summary> /// <param name="downloader">下载器</param> /// <param name="choker">阻塞器</param> /// <param name="piecesNumber">下载文件的片断数量</param> /// <param name="isEverythingPending"></param> /// <param name="totalUp">参数类</param> /// <param name="maxUploadRate">最大上传速率</param> /// <param name="scheduleFunction"></param> public Connecter(Downloader downloader, IChoker choker, int piecesNumber, PendingDelegate isEverythingPending, Measure totalUp, int maxUploadRate, SchedulerDelegate scheduleFunction) { this.downloader = downloader; this.choker = choker; this.piecesNumber = piecesNumber; this.isEverythingPending = isEverythingPending; this.maxUploadRate = maxUploadRate; this.scheduleFunction = scheduleFunction; this.totalUp = totalUp; this.rateCapped = false; this.connectionDictionary = new Dictionary <IEncryptedConnection, IConnection>(); this.endgame = false; this.CheckEndgame(); }
void StartScheduler() { var schedulerDelegate = new SchedulerDelegate { Logger = Logger }; scheduler = KayakScheduler.Factory.Create(schedulerDelegate); var endPoint1 = new IPEndPoint(IPAddress.Any, 91); var appDelegate = AppBuilder.BuildConfiguration(Startup.Configuration); using (KayakServer.Factory.CreateGate(appDelegate, scheduler, null) .Listen(endPoint1)) { scheduler.Start(); } }
public DownloaderFeedback(IChoker choker, SchedulerDelegate addTaskFunction, StatusDelegate statusFunction, MeasureRateDelegate uploadFunction, MeasureRateDelegate downloadFunction, MeasureRateDelegate remainingFunction, AmountDelegate leftFunction, long fileLength, Flag finishFlag, double interval, bool sp) { this.choker = choker; this.addTaskFunction = addTaskFunction; this.statusFunction = statusFunction; this.uploadFunction = uploadFunction; this.downloadFunction = downloadFunction; this.remainingFunction = remainingFunction; this.leftFunction = leftFunction; this.fileLength = fileLength; this.finishFlag = finishFlag; this.interval = interval; this.sp = sp; this.lastIDs = new List <byte[]>(); this.Display(); }
public SchedulerLimit(float interval, int count, SchedulerDelegate callback) : base(interval, callback) { MaxCount = count; }
/// <summary> /// 构造函数 /// </summary> /// <param name="downloader">下载器</param> /// <param name="choker">阻塞器</param> /// <param name="piecesNumber">下载文件的片断数量</param> /// <param name="isEverythingPending"></param> /// <param name="totalUp">参数类</param> /// <param name="maxUploadRate">最大上传速率</param> /// <param name="scheduleFunction"></param> public DummyConnecter(Downloader downloader, IChoker choker, int piecesNumber, PendingDelegate isEverythingPending, Measure totalUp, int maxUploadRate, SchedulerDelegate scheduleFunction) : base(downloader, choker, piecesNumber, isEverythingPending, totalUp, maxUploadRate, scheduleFunction) { }
public Scheduler(float interval, SchedulerDelegate callback) { Interval = interval; Callback = callback; }