-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeerProcess.java
45 lines (33 loc) · 1021 Bytes
/
peerProcess.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class peerProcess {
private static Torrent mainTorrent;
public static final ReadConfig config = new ReadConfig();
public static final FileSplitter fs = new FileSplitter();
public peerProcess(String peerId) {
mainTorrent = new Torrent(peerId);
}
public static void main(String[] args) throws Exception {
if(args[0].equals("1001")){
fs.mainHandler("TheFile.dat", 1);
}
peerProcess main = new peerProcess(args[0]);
fs.mkdir(args[0]);
try {
Thread.currentThread().sleep(1500);
} catch(InterruptedException ie) {
}
ShutdownHook sHook = new ShutdownHook();
Runtime.getRuntime().addShutdownHook(sHook);
mainTorrent.initialPeer();
new Thread( new Runnable() {
public void run() {
mainTorrent.file_download();
}
}).start();
mainTorrent.start();
}
private static class ShutdownHook extends Thread {
public void run() {
mainTorrent.shutdownTorrent();
}
}
}