Reorder
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Ping.pm
1 # $Id: Ping.pm,v 1.11 2006-09-13 16:29:55 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;
13 @ISA = qw(ZOOM::IRSpy::Test);
14
15
16 sub run {
17     my $this = shift();
18     my $irspy = $this->irspy();
19     my $pod = $irspy->pod();
20
21     $pod->callback(ZOOM::Event::CONNECT, \&connected);
22     $pod->callback("exception", \&not_connected);
23     my $err = $pod->wait($irspy);
24
25     return 0;
26 }
27
28
29 sub connected { maybe_connected(@_, 1) }
30 sub not_connected { maybe_connected(@_, 0) }
31
32 sub maybe_connected {
33     my($conn, $irspy, $rs, $event, $ok) = @_;
34
35     $irspy->log("irspy_test", $conn->option("host"),
36                 ($ok ? "" : " not"), " connected");
37     my $rec = $irspy->record($conn);
38     $rec->append_entry("irspy:status", "<irspy:probe ok='$ok'>" .
39                        $irspy->isodate(time()) . "</irspy:probe>");
40     $conn->option(pod_omit => 1) if !$ok;
41     return 0;
42 }
43
44
45 1;