Package transfer.download.logic

Source Code of transfer.download.logic.DownloadAttempter

package transfer.download.logic;


import transfer.download.FileDownloadConnection;
import transfer.download.FileDownloadConnector;

import common.connection.AbstractConnection;
import common.connection.client.AbstractClientSideConnector;
import common.connection.client.ConnectionAttempt;
import common.connection.client.ConnectionAttempterInterface;
import common.info.FileSource;


public class DownloadAttempter implements ConnectionAttempterInterface
{
  private AttemptManagerInterface manager;
  private AbstractConnection connection = null;

  public DownloadAttempter(AttemptManagerInterface manager, FileSource source)
  {
    this.manager = manager;
    new ConnectionAttempt(this, source.getAddress());
  }

  public AbstractClientSideConnector getConnector()
  {
    return new FileDownloadConnector(manager.getDownload(), this);
  }

  public void notifyConnected(FileDownloadConnection connection)
  {
    this.connection = connection;
    connection.requestFile();
  }

  public void notifyFullSuccess(FileDownloadConnection connection)
  {
    manager.notifyFullSuccess(connection);
  }

  public void notifyFailure()
  {
    manager.notifyFailure(this);
  }

  public void notifyInvalidFile()
  {
    manager.notifyFailure(this);
  }

  public void cancel()
  {
    if (connection != null)
    {
      connection.terminate();
    }
  }

}
TOP

Related Classes of transfer.download.logic.DownloadAttempter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.