PlatformTorrentMessengerpublic class PlatformTorrentMessenger extends Object
Fields Summary |
---|
public static String | LISTENER_ID | public static String | OP_GETMETADATA | public static String | OP_STREAMCOMPLETE |
Methods Summary |
---|
public static void | getMetaData(org.gudy.azureus2.core3.torrent.TOTorrent[] torrents, long maxDelayMS, com.aelitis.azureus.core.messenger.config.PlatformTorrentMessenger$GetMetaDataReplyListener replyListener)
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 void | streamComplete(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 void | streamComplete(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);
|
|