this.messageManager = networkManager.getMessageManager();
}
@Override
protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
PublicKeyManager keyManager;
try {
keyManager = networkManager.getSession().getKeyManager();
} catch (NoSessionException e) {
throw new ProcessExecutionException("No session yet");
}
Locations locations = context.consumeLocations();
waitForResponses = new CountDownLatch(locations.getPeerAddresses().size());
if (!locations.getPeerAddresses().isEmpty()) {
for (PeerAddress address : locations.getPeerAddresses()) {
// contact all other clients (exclude self)
if (!address.equals(networkManager.getConnection().getPeer().getPeerAddress())) {
String evidence = UUID.randomUUID().toString();
evidences.put(address, evidence);
ContactPeerMessage message = new ContactPeerMessage(address, evidence);
message.setCallBackHandler(this);
// TODO this is blocking, should be parallel (asynchronous)
boolean success = messageManager.sendDirect(message, keyManager.getOwnPublicKey());
if (!success) {
responses.put(address, false);
}
}
}