aboutsummaryrefslogtreecommitdiff
path: root/tests/DieSender.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/DieSender.java')
-rw-r--r--tests/DieSender.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/DieSender.java b/tests/DieSender.java
new file mode 100644
index 0000000..c44446b
--- /dev/null
+++ b/tests/DieSender.java
@@ -0,0 +1,43 @@
+/*
+ * sends die to the client specified by a string.
+ */
+import fr.dgac.ivy.* ;
+
+public class DieSender extends IvyApplicationAdapter {
+
+ private String tokill;
+ private int targets = 0;
+
+ public DieSender(Ivy bus,String mtokill) throws IvyException {
+ this.tokill=mtokill;
+ bus.addApplicationListener(this);
+ }
+
+ /*
+ public void disconnect(IvyClient c) {
+ System.out.println(c.getApplicationName());
+ if (c.getApplicationName().compareTo(tokill)==0) {
+ System.out.println(tokill+" left the bus");
+ }
+ }
+ */
+
+ public void connect(IvyClient c) {
+ if (c.getApplicationName().compareTo(tokill)==0) {
+ System.out.println("found a "+tokill+" on the bus, sending Die Message");
+ c.sendDie("meurs !");
+ }
+ }
+
+ public static final String DEFAULTTOKILL = "JPROBE" ;
+
+ public static void main(String[] args) throws IvyException {
+ String mtokill = DEFAULTTOKILL;
+ String domain = Ivy.getDomain(null);
+ System.out.println("will kill each and every " + mtokill + " on the " + domain +" bus");
+ Ivy bus = new Ivy("DieSender","DieSender ready",null);
+ bus.start(Ivy.getDomain(null));
+ new DieSender(bus,mtokill);
+ }
+
+}