Change la partie Discovery qui n'était pas claire
This commit is contained in:
@@ -2,19 +2,19 @@ package pr.tp2.udp.discovery;
|
|||||||
|
|
||||||
public class Discovery {
|
public class Discovery {
|
||||||
|
|
||||||
public static void handleWhois(String id) {
|
public static void sendWhois(String id) {
|
||||||
// Envoie un message Whois
|
// Envoie un message Whois
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleLeaving(String id) {
|
public static void sendLeaving(String id) {
|
||||||
// Envoie un message Leaving
|
// Envoie un message Leaving
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleIAM(String id, String url) {
|
public static void sendIAM(String id, String url) {
|
||||||
// Envoie un message IAM
|
// Envoie un message IAM
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleListen() {
|
public static void listenAndReply() {
|
||||||
// Ecoute et affiche les évennements IAM,LEAVING
|
// Ecoute et affiche les évennements IAM,LEAVING
|
||||||
|
|
||||||
// Réponds aux WHOIS si ID = ID
|
// Réponds aux WHOIS si ID = ID
|
||||||
@@ -35,16 +35,16 @@ public class Discovery {
|
|||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "listen":
|
case "listen":
|
||||||
handleListen();
|
listenAndReply();
|
||||||
break;
|
break;
|
||||||
case "iam":
|
case "iam":
|
||||||
handleIAM(id, url);
|
sendIAM(id, url);
|
||||||
break;
|
break;
|
||||||
case "leaving":
|
case "leaving":
|
||||||
handleLeaving(id);
|
sendLeaving(id);
|
||||||
break;
|
break;
|
||||||
case "whois":
|
case "whois":
|
||||||
handleWhois(id);
|
sendWhois(id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Erreur de commande");
|
System.out.println("Erreur de commande");
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ public class TestDiscovery {
|
|||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
Runnable listener = () -> {
|
Runnable listener = () -> {
|
||||||
Discovery.handleListen();
|
Discovery.listenAndReply();
|
||||||
};
|
};
|
||||||
new Thread(listener).start();
|
new Thread(listener).start();
|
||||||
|
|
||||||
Discovery.handleWhois("051005022");
|
Discovery.sendWhois("051005022");
|
||||||
Discovery.handleIAM("tftp", "127.0.0.1:6969");
|
Discovery.sendIAM("tftp", "127.0.0.1:6969");
|
||||||
|
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user