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 static void handleWhois(String id) {
public static void sendWhois(String id) {
// Envoie un message Whois
}
public static void handleLeaving(String id) {
public static void sendLeaving(String id) {
// Envoie un message Leaving
}
public static void handleIAM(String id, String url) {
public static void sendIAM(String id, String url) {
// Envoie un message IAM
}
public static void handleListen() {
public static void listenAndReply() {
// Ecoute et affiche les évennements IAM,LEAVING
// Réponds aux WHOIS si ID = ID
@@ -35,16 +35,16 @@ public class Discovery {
switch (cmd) {
case "listen":
handleListen();
listenAndReply();
break;
case "iam":
handleIAM(id, url);
sendIAM(id, url);
break;
case "leaving":
handleLeaving(id);
sendLeaving(id);
break;
case "whois":
handleWhois(id);
sendWhois(id);
break;
default:
System.out.println("Erreur de commande");

View File

@@ -4,12 +4,12 @@ public class TestDiscovery {
public static void main(String[] args) throws InterruptedException {
Runnable listener = () -> {
Discovery.handleListen();
Discovery.listenAndReply();
};
new Thread(listener).start();
Discovery.handleWhois("051005022");
Discovery.handleIAM("tftp", "127.0.0.1:6969");
Discovery.sendWhois("051005022");
Discovery.sendIAM("tftp", "127.0.0.1:6969");
Thread.sleep(10000);