Many radical changes to the IRSpy engine, enabling a far more asynchronous approach...
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Ping.pm
1 # $Id: Ping.pm,v 1.12 2006-10-06 11:33:08 mike Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Ping;
6
7 use 5.008;
8 use strict;
9 use warnings;
10
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
13
14
15 sub start {
16     my $class = shift();
17     my($conn) = @_;
18
19     $conn->irspy_connect(ZOOM::Event::CONNECT, \&connected,
20                          "exception", \&not_connected);
21 }
22
23
24 sub connected { maybe_connected(@_, 1) }
25 sub not_connected { maybe_connected(@_, 0) }
26
27 sub maybe_connected {
28     my($conn, $rs, $event, $ok) = @_;
29
30     $conn->log("irspy_test", ($ok ? "" : "not "), "connected");
31     my $rec = $conn->record();
32     $rec->append_entry("irspy:status", "<irspy:probe ok='$ok'>" .
33                        isodate(time()) . "</irspy:probe>");
34     $conn->option(pod_omit => 1) if !$ok;
35     return ZOOM::IRSpy::Status::TASK_DONE;
36 }
37
38
39 1;