use of me.matoosh.undernet.event.EventHandler in project UnderNet by itsMatoosh.
the class FileResource method onPushReceive.
/**
* Called after the resource push has been received.
*
* @param msg
* @param receivedFrom
*/
@Override
public void onPushReceive(ResourcePushMessage msg, Node receivedFrom) {
// Requesting the file trasnfer.
transfer = UnderNet.router.fileTransferManager.requestFileTransfer(receivedFrom, (FileResource) msg.resource);
EventManager.registerHandler(new EventHandler() {
@Override
public void onEventCalled(Event e) {
FileTransferFinishedEvent transferFinishedEvent = (FileTransferFinishedEvent) e;
if (transferFinishedEvent.transfer == FileResource.this.transfer) {
// Transfer of the resource has finished. The resource is ready to push.
onPushReady();
}
}
}, FileTransferFinishedEvent.class);
}
Aggregations