boolean compact, boolean noPeerId, RequestEvent event,
String ip, int numWant)
throws IOException, MessageValidationException,
UnsupportedEncodingException {
Map<String, BEValue> params = new HashMap<String, BEValue>();
params.put("info_hash", new BEValue(infoHash));
params.put("peer_id", new BEValue(peerId));
params.put("port", new BEValue(port));
params.put("uploaded", new BEValue(uploaded));
params.put("downloaded", new BEValue(downloaded));
params.put("left", new BEValue(left));
params.put("compact", new BEValue(compact ? 1 : 0));
params.put("no_peer_id", new BEValue(noPeerId ? 1 : 0));
if (event != null) {
params.put("event",
new BEValue(event.getEventName(), Torrent.BYTE_ENCODING));
}
if (ip != null) {
params.put("ip",
new BEValue(ip, Torrent.BYTE_ENCODING));
}
if (numWant != AnnounceRequestMessage.DEFAULT_NUM_WANT) {
params.put("numwant", new BEValue(numWant));
}
return new HTTPAnnounceRequestMessage(
BEncoder.bencode(params),
infoHash, new Peer(ip, port, ByteBuffer.wrap(peerId)),