|
|
@ -26,26 +26,35 @@ import java.net.UnknownHostException;
|
|
|
|
import java.net.SocketException;
|
|
|
|
import java.net.SocketException;
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
import serverP2P.ServerManagementUDP;
|
|
|
|
|
|
|
|
import serverP2P.ServerManagementTCP;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DownloadFileGUI extends JPanel{
|
|
|
|
public class DownloadFileGUI extends JPanel{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 13L;
|
|
|
|
private String fileToDownload;
|
|
|
|
private String fileToDownload;
|
|
|
|
private ClientManagement clientManagement;
|
|
|
|
private ClientManagement clientManagement;
|
|
|
|
private Logger logger;
|
|
|
|
private Logger logger;
|
|
|
|
private static final long serialVersionUID = 13L;
|
|
|
|
private ServerManagementTCP smtcp;
|
|
|
|
|
|
|
|
private ServerManagementUDP smudp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DownloadFileGUI(String fileToDownload, ClientManagement clientManagement, Logger logger){
|
|
|
|
public DownloadFileGUI(String fileToDownload, ClientManagement clientManagement, Logger logger, ServerManagementTCP smtcp, ServerManagementUDP smudp){
|
|
|
|
this.fileToDownload = fileToDownload;
|
|
|
|
this.fileToDownload = fileToDownload;
|
|
|
|
this.clientManagement = clientManagement;
|
|
|
|
this.clientManagement = clientManagement;
|
|
|
|
this.logger = logger;
|
|
|
|
this.logger = logger;
|
|
|
|
|
|
|
|
this.smtcp = smtcp;
|
|
|
|
|
|
|
|
this.smudp = smudp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void download() {
|
|
|
|
public void download() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
System.out.println("Downloading " + fileToDownload + " ... ");
|
|
|
|
System.out.println("Downloading " + fileToDownload + " ... ");
|
|
|
|
clientManagement.download(fileToDownload);
|
|
|
|
clientManagement.download(fileToDownload);
|
|
|
|
|
|
|
|
smudp.setStop();
|
|
|
|
|
|
|
|
smtcp.setStop();
|
|
|
|
ErrorFrame erreur = new ErrorFrame("File " + fileToDownload + " sucessfully downloaded");
|
|
|
|
ErrorFrame erreur = new ErrorFrame("File " + fileToDownload + " sucessfully downloaded");
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
ErrorFrame erreur = new ErrorFrame("File " + fileToDownload + " unsucessfully downloaded, wrong number");
|
|
|
|
ErrorFrame erreur = new ErrorFrame("File " + fileToDownload + " unsucessfully downloaded, wrong number");
|
|
|
|