// open as long as possible
FutureBootstrap masterAnother = peer1.bootstrap().peerAddress(peer2.peerAddress()).start();
FutureBootstrap anotherMaster = peer2.bootstrap().peerAddress(peer1.peerAddress()).start();
masterAnother.awaitUninterruptibly();
anotherMaster.awaitUninterruptibly();
FuturePeerConnection fpc = peer1.createPeerConnection(peer2.peerAddress());
// fpc.awaitUninterruptibly();
// PeerConnection peerConnection = fpc.peerConnection();
String sentObject = "Hello";
FutureDirect fd = peer1.sendDirect(fpc).object(sentObject).start();
System.out.println("send " + sentObject);
fd.awaitUninterruptibly();
Assert.assertEquals(true, fd.isSuccess());
System.out.println("received " + fd.object() + " connections: "
+ ccohTCP.total());
// we reuse the connection
long start = System.currentTimeMillis();
System.out.println("send " + sentObject);
fd = peer1.sendDirect(fpc).object(sentObject).start();
fd.awaitUninterruptibly();
System.err.println(fd.failedReason());
Assert.assertEquals(true, fd.isSuccess());
System.err.println(fd.failedReason());
System.out.println("received " + fd.object() + " connections: "
+ ccohTCP.total());
// now we don't want to keep the connection open anymore:
double duration = (System.currentTimeMillis() - start) / 1000d;
System.out.println("Send and get in s:" + duration);
fpc.close().await();
System.out.println("done");
} finally {
if (peer1 != null) {
peer1.shutdown().await();
System.out.println("done1");