Search in sources :

Example 1 with EventHandler

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);
}
Also used : FileTransferFinishedEvent(me.matoosh.undernet.event.ftp.FileTransferFinishedEvent) EventHandler(me.matoosh.undernet.event.EventHandler) FileTransferFinishedEvent(me.matoosh.undernet.event.ftp.FileTransferFinishedEvent) Event(me.matoosh.undernet.event.Event)

Aggregations

Event (me.matoosh.undernet.event.Event)1 EventHandler (me.matoosh.undernet.event.EventHandler)1 FileTransferFinishedEvent (me.matoosh.undernet.event.ftp.FileTransferFinishedEvent)1