Mercurial > projects > ldc
comparison tango/example/cluster/alert.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
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 } |