use of me.matoosh.undernet.event.resource.push.ResourceFinalStopEvent in project UnderNet by itsMatoosh.
the class ResourceManager method pushForward.
/**
* Forwards a pushMessage to the next appropriate node.
* Calls resource stored event if this node is the resource's destination.
* @param pushMessage
*/
public void pushForward(ResourcePushMessage pushMessage) {
// Getting the node closest to the resource.
Node closest = router.neighborNodesManager.getClosestTo(pushMessage.resource.networkID);
if (closest == Node.self) {
// This is the final node of the resource.
EventManager.callEvent(new ResourceFinalStopEvent(pushMessage.resource, pushMessage, null));
} else {
logger.info("Pushing resource: " + pushMessage.resource + " to node: " + closest);
// Calling the onPush method.
pushMessage.resource.onPush(pushMessage, closest);
// Sending the push msg.
closest.send(new NetworkMessage(MsgType.RES_PUSH, pushMessage));
// Calling event.
EventManager.callEvent(new ResourcePushSentEvent(pushMessage.resource, pushMessage, closest));
}
}
Aggregations