From: Stephen L Johnson Date: Tue, 22 Feb 2000 05:21:45 +0000 (+0000) Subject: added support for 'page' message type X-Git-Tag: spong-2_7-alpha5~73 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db3e409e92b53147db27fa698d76f8e0921bbd20;p=spong.git added support for 'page' message type --- diff --git a/src/lib/Spong/Status.pm b/src/lib/Spong/Status.pm index ccbd518..37fafc8 100755 --- a/src/lib/Spong/Status.pm +++ b/src/lib/Spong/Status.pm @@ -92,5 +92,38 @@ sub event { warn scalar(localtime) . " can't connect to spong server.\n" if ! $ok; } +sub page { + my( $addr, $host, $cat, $color, $summary, $message, $ttl ) = @_; + my( $sock, $ok, $ts ); + $ts = time(); + + $sock = IO::Socket::INET->new( PeerAddr => $addr, + PeerPort => $main::SPONG_UPDATE_PORT, + Proto => 'tcp', + Timeout => 30, + Reuse => 1, + ); + + if ( ! defined $sock ) { + croak "Could not connect with Spong Server: $@"; + } + + # Set an alarm on this block in case we run into problem talking to + # the spong server. + { + local $SIG{'ALRM'} = sub { die; }; + alarm(30); + + $sock->autoflush(1); + $sock->print("page $host $cat $color $ts $summary\n"); + $sock->print("$message\n"); + + undef $sock; + $ok = 1; + } + + alarm(0); + warn scalar(localtime) . " can't connect to spong server.\n" if ! $ok; +}