aboutsummaryrefslogtreecommitdiff
path: root/tests/Killer.java
blob: 4f95b1d06faabbc1c62a90cf5d3addf0bd0707d4 (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
/**
 * Ivy java library API tester.
 *
 * @author  Yannick Jestin <mailto:jestin@cena.fr>
 *
 * (c) CENA
 *
 */
import fr.dgac.ivy.*;

public class Killer implements IvyMessageListener {

  private Ivy kbus;
  private String killOnMsg;

  public Killer(String domain,String killOnMsg)  {
    try {
      System.out.println("Killer joining the bus");
      kbus = new Ivy("Killer","Killer ready", null);
      this.killOnMsg=killOnMsg;
      kbus.bindMsg(killOnMsg,this);
      kbus.start(domain);
    } catch (IvyException ie) {
      ie.printStackTrace();
    }
  }

  public void receive(IvyClient c,String[] args) {
    c.sendDie("bye bye ! you told me "+killOnMsg);
    System.out.println("Killer leaving the bus");
    kbus.stop();
    System.out.println("Killer has left the bus");
  }

  public static void main(String[] args) throws IvyException {
    new Killer(Ivy.getDomainArgs("Killer",args),"^coucou$");
  }

}