channelClientConfiguration, scheduledExecutorService, sendBehavior);
}
final Peer peer = new Peer(p2pID, peerId, peerCreator);
PeerBean peerBean = peerCreator.peerBean();
peerBean.addPeerStatusListener(peerMap);
ConnectionBean connectionBean = peerCreator.connectionBean();
peerBean.peerMap(peerMap);
peerBean.keyPair(keyPair);
if (bloomfilterFactory == null) {
peerBean.bloomfilterFactory(new DefaultBloomfilterFactory());
}
if (broadcastHandler == null) {
broadcastHandler = new DefaultBroadcastHandler(peer, new Random());
}
//Set/enable RPC
if (isEnableHandShakeRPC()) {
PingRPC pingRPC = new PingRPC(peerBean, connectionBean);
peer.pingRPC(pingRPC);
}
if (isEnableQuitRPC()) {
QuitRPC quitRPC = new QuitRPC(peerBean, connectionBean);
quitRPC.addPeerStatusListener(peerMap);
peer.quitRPC(quitRPC);
}
if (isEnableNeighborRPC()) {
NeighborRPC neighborRPC = new NeighborRPC(peerBean, connectionBean);
peer.neighborRPC(neighborRPC);
}
if (isEnableDirectDataRPC()) {
DirectDataRPC directDataRPC = new DirectDataRPC(peerBean, connectionBean);
peer.directDataRPC(directDataRPC);
}
if (isEnableBroadcast()) {
BroadcastRPC broadcastRPC = new BroadcastRPC(peerBean, connectionBean, broadcastHandler);
peer.broadcastRPC(broadcastRPC);
}
if (isEnableRouting() && isEnableNeighborRPC()) {
DistributedRouting routing = new DistributedRouting(peerBean, peer.neighborRPC());
peer.distributedRouting(routing);
}
if (maintenanceTask == null && isEnableMaintenance()) {
maintenanceTask = new MaintenanceTask();
}
if (maintenanceTask != null) {
maintenanceTask.init(peer, connectionBean.timer());
maintenanceTask.addMaintainable(peerMap);
}
peerBean.maintenanceTask(maintenanceTask);
// set the ping builder for the heart beat
connectionBean.sender().pingBuilderFactory(new PingBuilderFactory() {
@Override