diff options
author | jestin | 2002-03-07 14:13:30 +0000 |
---|---|---|
committer | jestin | 2002-03-07 14:13:30 +0000 |
commit | 61ac1763d6ae6455ac6962bcef931103c9298d61 (patch) | |
tree | ab427cbc53fe95deedb9c69824c2761ab18d899c /src/Probe.java | |
parent | 36739f8756462e6c6d6fbe0dd148b0d347775cd8 (diff) | |
download | ivy-java-61ac1763d6ae6455ac6962bcef931103c9298d61.zip ivy-java-61ac1763d6ae6455ac6962bcef931103c9298d61.tar.gz ivy-java-61ac1763d6ae6455ac6962bcef931103c9298d61.tar.bz2 ivy-java-61ac1763d6ae6455ac6962bcef931103c9298d61.tar.xz |
*** empty log message ***
Diffstat (limited to 'src/Probe.java')
-rw-r--r-- | src/Probe.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Probe.java b/src/Probe.java index a5238c1..7719e73 100644 --- a/src/Probe.java +++ b/src/Probe.java @@ -18,7 +18,6 @@ class Probe implements IvyApplicationListener, IvyMessageListener { public static final String helpmsg = "usage: java fr.dgac.ivy.Probe [options] [regexp]\n\t-b BUS\tspecifies the Ivy bus domain\n\t-q\tquiet, no tty output\n\t-d\tdebug\n\t-h\thelp\n\n\t regexp is a Perl5 compatible regular expression"; public static void main(String[] args) throws IvyException { - Probe p = new Probe(); Getopt opt = new Getopt("Probe",args,"b:dh"); int c; String domain=Ivy.getDomain(null); @@ -33,12 +32,12 @@ class Probe implements IvyApplicationListener, IvyMessageListener { default: System.out.println(helpmsg); System.exit(0); - } - // connexion to the Bus + } // getopt + Probe p = new Probe(); + Ivy bus=new Ivy("JPROBE","JPROBE ready",p); try { - Ivy bus=new Ivy("JPROBE","JPROBE ready",p); for (int i=opt.getOptind();i<args.length;i++) { - System.out.println("you want to subscribe to " + args[i]); + System.out.println("you want to subscribe to " + args[i]); bus.bindMsg(args[i],p); } System.out.println("broadcasting on "+domain); @@ -47,20 +46,26 @@ class Probe implements IvyApplicationListener, IvyMessageListener { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); // infinite loop on keyboard input try { - while (p.looping() && (s=in.readLine()).length()!=0) - System.out.println("-> Sent to " +bus.sendMsg(s)+" peers"); + while (p.looping()) { + if ( (s=in.readLine()).length()!=0) { + System.out.println("-> Sent to " +bus.sendMsg(s)+" peers"); + } + } } catch (NullPointerException e) { + // EOF triggered by a ^D, for instance bus.stop(); } catch (IOException e) { + System.out.println("ioe ?"); + e.printStackTrace(); bus.stop(); } } catch (IvyException ie) { System.out.println("Caught an exception. quitting. "+ie.getMessage()); } + System.exit(0); // quit ! } private boolean looping=true; - public boolean looping() { return looping ; } // accessor public void connect(IvyClient client) { |