132
|
1 private import tango.core.Thread;
|
|
2
|
|
3 private import tango.util.log.Configurator;
|
|
4
|
|
5 private import tango.net.cluster.NetworkAlert;
|
|
6
|
|
7 private import tango.net.cluster.tina.Cluster;
|
|
8
|
|
9 /*******************************************************************************
|
|
10
|
|
11 How to send and recieve Alert messages using tango.net.cluster
|
|
12
|
|
13 *******************************************************************************/
|
|
14
|
|
15 void main()
|
|
16 {
|
|
17 // hook into the cluster
|
|
18 auto cluster = (new Cluster).join;
|
|
19
|
|
20 // hook into the Alert layer
|
|
21 auto alert = new NetworkAlert (cluster, "my.kind.of.alert");
|
|
22
|
|
23 // listen for the broadcast (on this channel)
|
|
24 alert.createConsumer (delegate void (IEvent event)
|
|
25 {event.log.info ("Recieved alert on channel " ~ event.channel.name);}
|
|
26 );
|
|
27
|
|
28 // say what's going on
|
|
29 alert.log.info ("broadcasting alert");
|
|
30
|
|
31 // and send everyone an empty alert (on this channel)
|
|
32 alert.broadcast;
|
|
33
|
|
34 // wait for it to arrive ...
|
|
35 Thread.sleep(1);
|
|
36 }
|