aboutsummaryrefslogtreecommitdiff
path: root/tests/DieSender.java
blob: c44446b16f6cb87339a9a8163023a5d17be8edf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);
  }

}