aboutsummaryrefslogtreecommitdiff
path: root/examples/Counter.java
diff options
context:
space:
mode:
Diffstat (limited to 'examples/Counter.java')
-rw-r--r--examples/Counter.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/Counter.java b/examples/Counter.java
index 1275101..a1dffd1 100644
--- a/examples/Counter.java
+++ b/examples/Counter.java
@@ -1,10 +1,16 @@
/**
- * a software bus package geiger counter
+ * Yet another Ivy java program example
+ *
+ * a software bus message "geiger counter" displaying each and every second
+ * the number of messages sent on the bus during the past second, the past ten
+ * seconds and the past minute.
*
* @author Yannick Jestin
* @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a>
*
- * (c) CENA 1998-2002
+ * (c) CENA 1998-2003
+ * This program is provided as is, under the LGPL licence with the ivy-java
+ * package.
*
*/
import fr.dgac.ivy.* ;
@@ -34,6 +40,8 @@ public class Counter implements IvyMessageListener, Runnable {
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) {
@@ -59,7 +67,7 @@ public class Counter implements IvyMessageListener, Runnable {
}
totalminute+=secCount[counter]-secCount[moinune];
totaldix+=secCount[counter]-secCount[moindix];
- String s = "MessageCount "+ secCount[counter]+" "+totaldix+" "+totalminute;
+ String s = "stats:\t"+ secCount[counter]+"\t"+totaldix+"\t"+totalminute;
if (!quiet) { System.out.println(s); }
bus.sendMsg(s);
moinune=(moinune+1)%secCount.length;
@@ -72,7 +80,7 @@ public class Counter implements IvyMessageListener, Runnable {
public void receive(IvyClient client,String[] args) { secCount[counter]++; }
public static void main(String[] args) {
- String domain="127.255.255.255:2010";
+ String domain=Ivy.getDomain(null);
Getopt opt = new Getopt("Counter",args,"b:dhq");
int c;
boolean quiet=false;