aboutsummaryrefslogtreecommitdiff
path: root/examples/Counter.java
diff options
context:
space:
mode:
Diffstat (limited to 'examples/Counter.java')
-rw-r--r--examples/Counter.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/Counter.java b/examples/Counter.java
index 34ae576..3c4c93e 100644
--- a/examples/Counter.java
+++ b/examples/Counter.java
@@ -41,13 +41,12 @@ public class Counter implements IvyMessageListener, Runnable {
public static final String helpmsg = "usage: java Counter -[options]\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";
- public Counter(String domain,boolean quiet) {
+ public Counter(String domain,boolean quiet) throws IvyException {
this.quiet=quiet;
for (int j=0;j<secCount.length;j++) {secCount[j]=0;}
bus = new Ivy("Counter","Counter ready",null);
System.out.println(bus.domains(domain));
System.out.println("stats:\t1s\t10s\t1m");
- bus.bindMsg(".*",this);
bus.bindMsg("^EXHAUSTED$",new IvyMessageListener(){
public void receive(IvyClient client,String[] args) {
isRunning=false;
@@ -74,7 +73,7 @@ public class Counter implements IvyMessageListener, Runnable {
totaldix+=secCount[counter]-secCount[moindix];
String s = "stats:\t"+ secCount[counter]+"\t"+totaldix+"\t"+totalminute;
if (!quiet) { System.out.println(s); }
- bus.sendMsg(s);
+ try { bus.sendMsg(s); } catch (IvyException ie) { }
moinune=(moinune+1)%secCount.length;
moindix=(moindix+1)%secCount.length;
counter=(counter+1)%secCount.length;
@@ -84,7 +83,7 @@ public class Counter implements IvyMessageListener, Runnable {
public void receive(IvyClient client,String[] args) { secCount[counter]++; }
- public static void main(String[] args) {
+ public static void main(String[] args) throws IvyException {
String domain=Ivy.getDomain(null);
Getopt opt = new Getopt("Counter",args,"b:dhq");
int c;