-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebugReceiver.java
44 lines (35 loc) · 1.25 KB
/
DebugReceiver.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
/* Le Hénaff Pablo ; Basudan Hossam*/
import java.util.concurrent.LinkedBlockingDeque;
public class DebugReceiver implements SimpleMessageHandler, Runnable {
private LinkedBlockingDeque<String> incoming = new LinkedBlockingDeque<String>(20);
private MuxDemuxSimple myMuxDemux = null;
public void setMuxDemux(MuxDemuxSimple md){
myMuxDemux = md;
}
public void handleMessage(String m){
try {
incoming.put(m);
} catch (InterruptedException e) {
System.err.println(e);
}
}
//Sender Thread
public void run(){
while (true) {
String msg = null;
try {
msg = incoming.take();
} catch (InterruptedException e) {
System.err.println(e);
}
// Handle message (debug)
String[] split = msg.split("/");
// if(Test.DEBUG)
System.out.println("DebugReceiver_rawMessage = " + split[0]);
System.out.println(myMuxDemux.toStringPeerTable());
System.out.println(myMuxDemux.toStringOthersDatabases());
// othersDatabases.put("ok", new Database(10));
// othersDatabases.get("ok").stringQueue.add("trying");
}
}
}