aboutsummaryrefslogtreecommitdiff
path: root/src/Probe.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Probe.java')
-rw-r--r--src/Probe.java21
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) {