aboutsummaryrefslogtreecommitdiff
path: root/examples/Counter.java
diff options
context:
space:
mode:
authorjestin2004-07-27 16:21:24 +0000
committerjestin2004-07-27 16:21:24 +0000
commit9ab98e8b79688821f85649fa3a04137f83467b73 (patch)
treeec55f2feb85355cadaf901bd561cd37444ae83ba /examples/Counter.java
parent9eff9570e518daccec02dd62593294341f4c36b6 (diff)
downloadivy-java-9ab98e8b79688821f85649fa3a04137f83467b73.zip
ivy-java-9ab98e8b79688821f85649fa3a04137f83467b73.tar.gz
ivy-java-9ab98e8b79688821f85649fa3a04137f83467b73.tar.bz2
ivy-java-9ab98e8b79688821f85649fa3a04137f83467b73.tar.xz
clean up the examples to abide to the new API
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;