|
|
@ -41,13 +41,15 @@ public class ClientDownloadPartUDP implements Runnable {
|
|
|
|
private volatile boolean noTask;
|
|
|
|
private volatile boolean noTask;
|
|
|
|
private String partsSubdir;
|
|
|
|
private String partsSubdir;
|
|
|
|
private static final long MAX_PARTIAL_SIZE = 4096;
|
|
|
|
private static final long MAX_PARTIAL_SIZE = 4096;
|
|
|
|
|
|
|
|
private ClientDownloadUDP manager;
|
|
|
|
|
|
|
|
|
|
|
|
/** Constructor with filename, socket, and part subdir
|
|
|
|
/** Constructor with filename, socket, and part subdir
|
|
|
|
* @param filename name of file to download
|
|
|
|
* @param filename name of file to download
|
|
|
|
* @param socket socket to use
|
|
|
|
* @param socket socket to use
|
|
|
|
* @param partsSubdir directory to store .part files
|
|
|
|
* @param partsSubdir directory to store .part files
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public ClientDownloadPartUDP(String filename, DatagramSocket socket, String partsSubdir) {
|
|
|
|
public ClientDownloadPartUDP(ClientDownloadUDP manager, String filename, DatagramSocket socket, String partsSubdir) {
|
|
|
|
|
|
|
|
this.manager = manager;
|
|
|
|
this.partsSubdir = partsSubdir;
|
|
|
|
this.partsSubdir = partsSubdir;
|
|
|
|
this.filename = filename;
|
|
|
|
this.filename = filename;
|
|
|
|
this.socket = socket;
|
|
|
|
this.socket = socket;
|
|
|
@ -80,9 +82,15 @@ public class ClientDownloadPartUDP implements Runnable {
|
|
|
|
while(!stop) {
|
|
|
|
while(!stop) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
doTasks();
|
|
|
|
doTasks();
|
|
|
|
|
|
|
|
synchronized(manager) {
|
|
|
|
|
|
|
|
manager.notify();
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch(InterruptedException e) {
|
|
|
|
} catch(InterruptedException e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
setStop();
|
|
|
|
setStop();
|
|
|
|
|
|
|
|
synchronized(manager) {
|
|
|
|
|
|
|
|
manager.notify();
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (InterruptedException e2) {
|
|
|
|
} catch (InterruptedException e2) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -168,6 +176,7 @@ public class ClientDownloadPartUDP implements Runnable {
|
|
|
|
} catch (IndexOutOfBoundsException e) {
|
|
|
|
} catch (IndexOutOfBoundsException e) {
|
|
|
|
noTask = true;
|
|
|
|
noTask = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|