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

📄 btgetrequest.java

📁 p2p仿真
💻 JAVA
字号:
/*
 * @(#)BTGetRequest.java	ver 1.2  6/20/2005
 *
 * Copyright 2005 Weishuai Yang (wyang@cs.binghamton.edu). 
 * All rights reserved.
 * 
 */

package gps.protocol.BT.param;
import gps.protocol.BT.BTPeer;
import gps.protocol.BT.BTSession;


/**
 * includes informations in the get command from peer to server.
 * 
 * Tracker GET request includes the following keys:
 * info_hash: hash key of the intened document
 * peer_id
 * ip
 * port
 * uploaded
 * downloaded
 * left
 * event: started, completed, or stopped, or empty
 *
 * In our simulation, only relavent information is included
 * the get request is identified by docHashKey
 * 
 * @author  Weishuai Yang
 * @version 1.2,  6/20/2005
 */
public class BTGetRequest {
	
	 /**
	  * download first begins
	  */
	 public static final int STARTED=1;
	 /**
	  * download finished
	  */
	 public static final int COMPLETED=2;
	 /**
	  * download cancelled
	  */
	 public static final int STOPPED=3;
	 /**
	  * document hash key
	  */
	 public String mDocHashKey=null;
	 /**
	  * request type
	  */
	 public int mEvent=0;
	 /**
	  * left amount
	  */
	 public double mLeft=0;
	 /**
	  * reference back to BTSession object that send out the request
	  */
	 public BTSession mBTSession=null;
	 /**
	  * reference back to BTPeer
	  */
	 public BTPeer mBTPeer=null;
	 /**
	  * constructs new request object
	  * @param hashKey document hash key
	  * @param event request type
	  * @param left left size
	  * @param session requesting session
	  */
	 public BTGetRequest(String hashKey, int event, double left, BTSession session){
	 	mDocHashKey=hashKey;
	 	mEvent=event;
	 	mLeft=left;
	 	mBTSession=session;
	 	mBTPeer=session.getAgent();
	 }
	 
	 /**
	  * gets string description of request
	  * 
	  * @return string description of request
	  */
	 public String eventToString(){
	 	switch(mEvent){
	 		case 0: return "EMPTY";
	 		case 1: return "STARTED";
	 		case 2: return "COMPLETED";
	 		case 3: return "STOPPED";
	 	}
	 	return "";
	 }
	 
		/**
		 * gets string description of request
		 * @return string description
		 */
		public String toString(){
			return eventToString();
		}
}

⌨️ 快捷键说明

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