FileDocCategorySizeDatePackage
PlatformTorrentMessenger.javaAPI DocAzureus 3.0.3.44680Tue Sep 25 17:25:40 BST 2007com.aelitis.azureus.core.messenger.config

PlatformTorrentMessenger

public class PlatformTorrentMessenger extends Object
author
TuxPaper
created
Oct 13, 2006

Fields Summary
public static String
LISTENER_ID
public static String
OP_GETMETADATA
public static String
OP_STREAMCOMPLETE
Constructors Summary
Methods Summary
public static voidgetMetaData(org.gudy.azureus2.core3.torrent.TOTorrent[] torrents, long maxDelayMS, com.aelitis.azureus.core.messenger.config.PlatformTorrentMessenger$GetMetaDataReplyListener replyListener)

param
torrent
param
maxDelayMS
param
replyListener
since
3.0.0.7


	   
	
		  

		     
	

	        	 
	      
			   
		Map mapParameters = new HashMap();
		List listContent = new ArrayList();
		List listHashes = new ArrayList();
		mapParameters.put("content-list", listContent);
		if (PlatformConfigMessenger.getRPCVersion() == 0) {
			// legacy support
			mapParameters.put("hashes", listHashes);
		}

		for (int i = 0; i < torrents.length; i++) {
			TOTorrent torrent = torrents[i];
			String hash = null;
			try {
				hash = torrent.getHashWrapper().toBase32String();
			} catch (TOTorrentException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			if (hash != null) {
				listHashes.add(hash);

				Map jsonSubObject = new HashMap();
				listContent.add(jsonSubObject);
				jsonSubObject.put("hash", hash);
				jsonSubObject.put("last-revision", new Long(
						PlatformTorrentUtils.getContentLastUpdated(torrent)));
			}
		}

		PlatformMessage message = new PlatformMessage("AZMSG", LISTENER_ID,
				OP_GETMETADATA, mapParameters, maxDelayMS);

		PlatformMessengerListener listener = new PlatformMessengerListener() {
			public void messageSent(PlatformMessage message) {
				replyListener.messageSent();
			}

			public void replyReceived(PlatformMessage message, String replyType,
					Map reply) {
				if (reply != null) {
					replyListener.replyReceived(replyType, reply);
				} else {
					replyListener.replyReceived(replyType, new HashMap());
				}
			}
		};

		PlatformMessenger.queueMessage(message, listener);
	
public static voidstreamComplete(org.gudy.azureus2.core3.torrent.TOTorrent torrent, long waitTime, int maxSeekAheadSecs, int numRebuffers, int numHardRebuffers)

		String hash = null;
		try {
			hash = torrent.getHashWrapper().toBase32String();
		} catch (TOTorrentException e) {
		}

		if (hash == null) {
			return;
		}

		Map mapParameters = new HashMap();

		mapParameters.put("torrent-hash", hash);
		mapParameters.put("wait-time", new Long(waitTime));
		mapParameters.put("max-seek", new Long(maxSeekAheadSecs));
		mapParameters.put("num-rebuffers", new Long(numRebuffers));
		mapParameters.put("num-hard-rebuffers", new Long(numHardRebuffers));

		PlatformMessage message = new PlatformMessage("AZMSG", LISTENER_ID,
				OP_STREAMCOMPLETE, mapParameters, 3000);

		PlatformMessenger.queueMessage(message, null);
	
public static voidstreamComplete(org.gudy.azureus2.core3.torrent.TOTorrent torrent, java.util.Map info)

		String hash = null;
		try {
			hash = torrent.getHashWrapper().toBase32String();
		} catch (TOTorrentException e) {
		}

		if (hash == null) {
			return;
		}

		Map mapParameters = new HashMap(info);

		mapParameters.put("torrent-hash", hash);

		PlatformMessage message = new PlatformMessage("AZMSG", LISTENER_ID,
				OP_STREAMCOMPLETE, mapParameters, 3000);

		PlatformMessenger.queueMessage(message, null);