ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/schmorplog.ext
(Generate patch)

Comparing deliantra/server/ext/schmorplog.ext (file contents):
Revision 1.11 by root, Wed Nov 14 08:09:46 2007 UTC vs.
Revision 1.12 by root, Mon Jan 7 01:55:19 2008 UTC

1#! perl # depends=irc 1#! perl # depends=irc
2 2
3use Fcntl;
4use Coro::AIO;
5
3our $UPDATE_LOGINS = EV::idle Coro::unblock_sub { 6our $UPDATE_LOGINS = EV::idle sub {
4 $_[0]->stop; 7 $_[0]->stop;
5 8
9 cf::async {
6 my ($status, @pl) = ext::commands::who_listing; 10 my ($status, @pl) = ext::commands::who_listing;
7 11
8 #TODO: write files asynchronously 12 my $fh = aio_open "$LOCALDIR/usercount", O_WRONLY | O_CREAT | O_TRUNC, 0644
9 open my $fh, ">", "$LOCALDIR/usercount"; 13 or return;
10 print $fh scalar @pl; 14 aio_write $fh, 0, undef, scalar @pl, 0;
15 aio_close $fh;
11 16
12 open my $fh, ">", "$LOCALDIR/userlisting.html"; 17 my $who;
13 for ($status, @pl) { 18 for ($status, @pl) {
14 s/[<&]//g; 19 s/[<&]//g;
15 print $fh "$_<br />\n"; 20 $who .= "$_<br />\n";
21 }
22
23 my $fh = aio_open "$LOCALDIR/userlisting.html", O_WRONLY | O_CREAT | O_TRUNC, 0644
24 or return;
25 aio_write $fh, 0, undef, $who, 0;
26 aio_close $fh;
16 } 27 };
17}; 28};
18 29
19cf::player->attach ( 30cf::player->attach (
20 on_login => sub { 31 on_login => sub {
21 my ($pl) = @_; 32 my ($pl) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines