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

📄 downloadmanager2.java

📁 peeranha42是jxta的 p2p程序核心
💻 JAVA
字号:
package de.uni_bremen.informatik.p2p.plugins.filesharing.network.download.server;

import java.io.IOException;
import java.util.ArrayList;
import net.jxta.protocol.PipeAdvertisement;
import org.apache.log4j.Logger;
import de.uni_bremen.informatik.p2p.peeranha42.core.network.NetworkException;
import de.uni_bremen.informatik.p2p.peeranha42.core.network.connection.BiDiServer;
import de.uni_bremen.informatik.p2p.plugins.filesharing.data.FilesharingState;

/**
 * @author Lars Kordes
 */
public class DownloadManager2 extends Thread {
	private ArrayList shares;
	private BiDiServer bidisrv;
	
	/** Logger for warnings, debugs and fatals */
    protected static Logger log = Logger.getLogger(DownloadManager2.class);
	
	public DownloadManager2(ArrayList shares, PipeAdvertisement arg1) throws NetworkException {
		this.shares = shares;
		
		bidisrv = new BiDiServer(FilesharingState.peergroup , arg1, 0);
		if(bidisrv == null) throw new NetworkException("Could not start download service.");
		try {
			FilesharingState.peergroup.getDiscoveryService().publish(arg1);
		} catch (IOException e) {
			throw new NetworkException("Could not publish Advertisement: "+e.toString());
		}
		FilesharingState.peergroup.getDiscoveryService().remotePublish(arg1);
	}
	
	public void run() {
		while(true) {
			  try {
			  	DownloadServer con = new DownloadServer(bidisrv.accept(), shares);
			  }
			  catch(NetworkException e) { log.error("\n___" + e); }
		}
	}
	
}

⌨️ 快捷键说明

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