Change la partie Discovery qui n'était pas claire

This commit is contained in:
ynn
2019-01-28 17:55:57 +01:00
parent be2e3f3350
commit 5d79088da6
2 changed files with 11 additions and 11 deletions

View File

@@ -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");

View File

@@ -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);