-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.java
52 lines (44 loc) · 1.8 KB
/
Test.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
46
47
48
49
50
51
52
/* Le Hénaff Pablo ; Basudan Hossam*/
import java.io.File;
import java.net.*;
public class Test {
public static final boolean DEBUG = true;
public static final int PORTNO = 4242;
public static final int HELLOINTERVAL = 60; //in s
public static final int SENDINGPERIOD = 5000; //in ms
public static final int FOLDERCHECKINTERVAL = 5000;
public static final String MYID = "pablo";
public static final String ROOTFOLDERERPATH = "/home/"+MYID+"/rootfolder/";
public static final String SHAREDFOLDERPATH = ROOTFOLDERERPATH+"mysharedfilesfolder/"; // with finishing / (important) !
public static void main (String[] args){
//GIT TEST HOSSAM
//EXO3
// HelloMessage h = new HelloMessage("HELLO;Bob;42;60;2;Kan;Pab");
// h.addPeer("hoss");
// System.out.println(h.getHelloMessageAsEncodedString());
// System.out.println(h);
//EXO6
DatagramSocket mySocket = null;
try {
mySocket = new DatagramSocket(PORTNO);
mySocket.setBroadcast(true);
} catch (SocketException e) {
e.printStackTrace();
}
SimpleMessageHandler[] handlers = new SimpleMessageHandler[8];
handlers[0]= new HelloSender();
handlers[1]= new HelloReceiver();
handlers[2]= new DebugReceiver();
handlers[3]= new SynReceiver();
handlers[4]= new SynSender();
handlers[5]= new ListReceiver();
handlers[6]= new SharedFolderHandler();
handlers[7]= new FileDownloader();
MuxDemuxSimple dm = new MuxDemuxSimple(handlers, mySocket);
new Thread(dm).start();
new Thread(new FileServer()).start();
for( int i = 0 ; i<handlers.length ; i++){
new Thread((Runnable) handlers[i]).start();
}
}
}