ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/eg/chat_server
Revision: 1.5
Committed: Fri Aug 14 15:53:56 2009 UTC (14 years, 9 months ago) by root
Branch: MAIN
CVS Tags: rel-0_7
Changes since 1.4: +1 -4 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 use common::sense;
4 use AnyEvent::MP;
5
6 initialise_node;
7
8 my %clients;
9
10 sub msg {
11 print "relaying: $_[0]\n";
12 snd $_, $_[0]
13 for values %clients;
14 }
15
16 sub client_connect {
17 my ($client, $name) = @_;
18
19 mon $client;
20 mon $client, sub {
21 delete $clients{$client};
22 msg "$name (quits, @_)";
23 };
24
25 $clients{$client} = $client;
26
27 msg "$name (joins)";
28
29 rcv $SELF, sub { msg "$name: $_[0]" };
30 }
31
32 warn "server ready.\n";
33
34 AE::cv->recv;