PlatformRatingMessengerpublic class PlatformRatingMessenger extends Object
Fields Summary |
---|
public static final String | LISTENER_ID | public static final String | OP_GET | public static final String | OP_SET | public static final String | RATE_TYPE_CONTENT | public static final ArrayList | listeners |
Methods Summary |
---|
public static void | addListener(com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$RatingUpdateListener l)
listeners.add(l);
| public static void | getGlobalRating(java.lang.String[] rateTypes, java.lang.String[] torrentHashes, long maxDelayMS, com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$GetRatingReplyListener replyListener)
PlatformMessage message = new PlatformMessage("AZMSG", "rating",
"get-global", new Object[] {
"rating-type",
rateTypes,
"torrent-hash",
torrentHashes,
}, maxDelayMS);
PlatformMessengerListener listener = new PlatformMessengerListener() {
public void messageSent(PlatformMessage message) {
replyListener.messageSent();
}
public void replyReceived(PlatformMessage message, String replyType,
Map reply) {
replyListener.replyReceived(replyType, new GetRatingReply(reply));
}
};
PlatformMessenger.queueMessage(message, listener);
| public static void | getUserRating(java.lang.String[] rateTypes, java.lang.String[] torrentHashes, long maxDelayMS, com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$GetRatingReplyListener replyListener)
PlatformMessage message = new PlatformMessage("AZMSG", "rating",
"get-user", new Object[] {
"rating-type",
rateTypes,
"torrent-hash",
torrentHashes,
}, maxDelayMS);
PlatformMessengerListener listener = new PlatformMessengerListener() {
public void messageSent(PlatformMessage message) {
replyListener.messageSent();
}
public void replyReceived(PlatformMessage message, String replyType,
Map reply) {
replyListener.replyReceived(replyType, new GetRatingReply(reply));
}
};
PlatformMessenger.queueMessage(message, listener);
| private static void | invokeUpdateListeners(com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$GetRatingReply rating)
Object[] listArray = listeners.toArray();
for (int i = 0; i < listArray.length; i++) {
RatingUpdateListener l = (RatingUpdateListener) listArray[i];
try {
l.ratingUpdated(rating);
} catch (Exception e) {
}
}
| public static boolean | ratingSucceeded(java.util.Map map)
String message = MapUtils.getMapString(map, "message", null);
if (message != null) {
return message.equals("Ok");
}
return MapUtils.getMapBoolean(map, "success", false);
| public static void | removeListener(com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$RatingUpdateListener l)
listeners.remove(l);
| public static void | setUserRating(java.lang.String torrentHash, int rating, long maxDelayMS, com.aelitis.azureus.core.messenger.PlatformMessengerListener l)
List array = new ArrayList();
array.add(PlatformMessage.parseParams(new Object[] {
"rating-type",
"content",
"rating-value",
new Integer(rating)
}));
PlatformMessage message = new PlatformMessage("AZMSG", "rating", "set",
new Object[] {
"torrent-hash",
torrentHash,
"ratings",
array
}, maxDelayMS);
PlatformMessenger.queueMessage(message, new PlatformMessengerListener() {
// @see com.aelitis.azureus.core.messenger.PlatformMessengerListener#messageSent(com.aelitis.azureus.core.messenger.PlatformMessage)
public void messageSent(PlatformMessage message) {
if (l != null) {
l.messageSent(message);
}
}
// @see com.aelitis.azureus.core.messenger.PlatformMessengerListener#replyReceived(com.aelitis.azureus.core.messenger.PlatformMessage, java.lang.String, java.lang.Object)
public void replyReceived(PlatformMessage message, String replyType,
Map reply) {
if (l != null) {
l.replyReceived(message, replyType, reply);
}
}
});
|
|