return true;
} else if (m.getSpec().equals(DMT.joinRequest)) {
final Integer uid = new Integer(m.getInt(DMT.UID));
if (!_seenUids.contains(uid)) {
_seenUids.add(uid);
new AbstractThread() {
protected boolean loop() throws InterruptedException {
handleJoinRequest(m);
_seenUids.remove(uid);
return false;
}
protected void cleanUp() {
}
}.startThread();
} else {
_usm.send(m.getSource(), DMT.createRejectDueToLoop(m.getInt(DMT.UID)));
}
return true;
} else if (m.getSpec().equals(DMT.requestData)) {
final Integer uid = new Integer(m.getInt(DMT.UID));
if (!_seenUids.contains(uid)) {
_seenUids.add(uid);
new AbstractThread() {
protected boolean loop() throws InterruptedException {
try {
_usm.send(m.getSource(), DMT.createAcknowledgeRequest(m.getInt(DMT.UID)));
PartiallyReceivedBlock prb = new PartiallyReceivedBlock(Dijjer.PACKETS_IN_BLOCK,
Dijjer.PACKET_SIZE);
retrieveData(new BlockInfo(m), m.getInt(DMT.TTL), m.getSource(), m.getInt(DMT.UID),
(LinkedList) m.getObject(DMT.FORWARDERS), prb, null);
_seenUids.remove(uid);
} catch (Exception e) {
Logger.warning("Error while retrieving data for another peer", e);
}
return false;
}
protected void cleanUp() {
}
}.startThread();
} else {
_usm.send(m.getSource(), DMT.createRejectDueToLoop(m.getInt(DMT.UID)));
}
return true;
} else if (m.getSpec().equals(DMT.requestHash)) {
final Integer uid = new Integer(m.getInt(DMT.UID));
if (!_seenUids.contains(uid)) {
_seenUids.add(uid);
new AbstractThread() {
public boolean loop() {
try {
_usm.send(m.getSource(), DMT.createRequestHashAck(m.getInt(DMT.UID)));
VeryLongInteger hash = retrieveHash(new BlockInfo(m), m.getInt(DMT.TTL), m.getInt(DMT.UID),
true);
_usm.send(m.getSource(), DMT.createReplyHash(m.getInt(DMT.UID), hash));
_seenUids.remove(uid);
} catch (Exception e) {
Logger.error(e);
throw new RuntimeException(e);
}
return false;
}
}.startThread();
} else {
_usm.send(m.getSource(), DMT.createRejectDueToLoop(m.getInt(DMT.UID)));
}
return true;
} else if (m.getSpec().equals(DMT.corruptionNotification)) {
final Integer uid = new Integer(m.getInt(DMT.UID));
if (!_seenUids.contains(uid)) { // We don't bother with the rejectDueToLoop
_seenUids.add(uid);
new AbstractThread() {
public boolean loop() {
try {
handleCorruptionNotification(new BlockInfo(m), m.getInt(DMT.UID), m.getSource(), m
.getBoolean(DMT.IS_HASH));