aboutsummaryrefslogtreecommitdiff
path: root/tests/DieSender.java
blob: a19854f08afca0899b0ed027cd3b3445fcb06600 (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 = Domain.getDomainArgs("DieSender",args);
    System.out.println("will kill each and every " + mtokill + " on the " + domain +" bus");
    Ivy bus = new Ivy("DieSender","DieSender ready",null);
    bus.start(domain);
    new DieSender(bus,mtokill);
  }

}