From cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319 Mon Sep 17 00:00:00 2001 From: jestin Date: Wed, 10 Oct 2001 15:36:44 +0000 Subject: Bugfix related to the "a(.*) (.*)' regexp causing the loss of front empty messages. --- src/Probe.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/Probe.java') diff --git a/src/Probe.java b/src/Probe.java index 84e282f..6e4543b 100644 --- a/src/Probe.java +++ b/src/Probe.java @@ -12,11 +12,11 @@ import java.io.*; */ class Probe implements IvyApplicationListener, IvyMessageListener { - public static void main(String[] args) { + public static void main(String[] args) throws IvyException { Probe p = new Probe(); Getopt opt = new Getopt("Probe",args,"b:d"); int c; - String domain=Ivy.DEFAULT_DOMAIN; + String domain=Ivy.getDomain(null); while ((c = opt.getopt()) != -1) switch (c) { case 'b': domain=opt.getOptarg(); @@ -37,11 +37,10 @@ class Probe implements IvyApplicationListener, IvyMessageListener { System.out.println("broadcasting on "+domain); bus.start(domain); String s; - BufferedReader in = - new BufferedReader(new InputStreamReader(System.in)); + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); // infinite loop on keyboard input try { - while ((s=in.readLine()).length()!=0) + while (p.looping() && (s=in.readLine()).length()!=0) System.out.println("-> Sent to " +bus.sendMsg(s)+" peers"); } catch (NullPointerException e) { bus.stop(); @@ -53,6 +52,10 @@ class Probe implements IvyApplicationListener, IvyMessageListener { } } + private boolean looping=true; + + public boolean looping() { return looping ; } // accessor + public void connect(IvyClient client) { System.out.println(client.getApplicationName() + " connected " ); for (java.util.Enumeration e=client.getRegexps();e.hasMoreElements();) @@ -65,7 +68,8 @@ class Probe implements IvyApplicationListener, IvyMessageListener { } public void die(IvyClient client, int id) { - System.out.println(client.getApplicationName() + " die "+ id ); + looping=false; + System.out.println(client.getApplicationName() + " received die msg from "+ id ); } public void directMessage(IvyClient client, int id, String arg) { -- cgit v1.1