]> git.etc.gen.nz Git - spong.git/commitdiff
added support for 'page' message type
authorStephen L Johnson <sjohnson@monsters.org>
Tue, 22 Feb 2000 05:21:45 +0000 (05:21 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Tue, 22 Feb 2000 05:21:45 +0000 (05:21 +0000)
src/lib/Spong/Status.pm

index ccbd5188a37ad612622e318e12301c8c1497d134..37fafc863e8fa9f14fa4c0f6b534690296a258b4 100755 (executable)
@@ -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;
+}