Running version -- does not yet register the results of its probing.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Ping.pm
1 # $Id: Ping.pm,v 1.3 2006-06-21 16:10:18 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     my $err = $pod->wait($irspy);
23
24     return 0;
25 }
26
27
28 sub connected {
29     my($conn, $irspy, $rs, $event) = @_;
30
31     my $rec = $irspy->record($conn);
32     $irspy->log("irspy_test", $conn->option("host"), " connected");
33     ### Note the successful connection in $rec
34     return 0;
35 }
36
37
38 # Some of this Pod-using code may be useful.
39 #
40 #$pod->option(elementSetName => "b");
41 #$pod->callback(ZOOM::Event::RECV_SEARCH, \&completed_search);
42 #$pod->callback(ZOOM::Event::RECV_RECORD, \&got_record);
43 ##$pod->callback(exception => \&exception_thrown);
44 #$pod->search_pqf("the");
45 #my $err = $pod->wait();
46 #die "$pod->wait() failed with error $err" if $err;
47 #
48 #sub completed_search {
49 #    my($conn, $state, $rs, $event) = @_;
50 #    print $conn->option("host"), ": found ", $rs->size(), " records\n";
51 #    $state->{next_to_fetch} = 0;
52 #    $state->{next_to_show} = 0;
53 #    request_records($conn, $rs, $state, 2);
54 #    return 0;
55 #}
56 #
57 #sub got_record {
58 #    my($conn, $state, $rs, $event) = @_;
59 #
60 #    {
61 #       # Sanity-checking assertions.  These should be impossible
62 #       my $ns = $state->{next_to_show};
63 #       my $nf = $state->{next_to_fetch};
64 #       if ($ns > $nf) {
65 #           die "next_to_show > next_to_fetch ($ns > $nf)";
66 #       } elsif ($ns == $nf) {
67 #           die "next_to_show == next_to_fetch ($ns)";
68 #       }
69 #    }
70 #
71 #    my $i = $state->{next_to_show}++;
72 #    my $rec = $rs->record($i);
73 #    print $conn->option("host"), ": record $i is ", render_record($rec), "\n";
74 #    request_records($conn, $rs, $state, 3)
75 #       if $i == $state->{next_to_fetch}-1;
76 #
77 #    return 0;
78 #}
79 #
80 #sub exception_thrown {
81 #    my($conn, $state, $rs, $exception) = @_;
82 #    print "Uh-oh!  $exception\n";
83 #    return 0;
84 #}
85 #
86 #sub request_records {
87 #    my($conn, $rs, $state, $count) = @_;
88 #
89 #    my $i = $state->{next_to_fetch};
90 #    ZOOM::Log::log("irspy", "requesting $count records from $i");
91 #    $rs->records($i, $count, 0);
92 #    $state->{next_to_fetch} += $count;
93 #}
94 #
95 #sub render_record {
96 #    my($rec) = @_;
97 #
98 #    return "undefined" if !defined $rec;
99 #    return "'" . $rec->render() . "'";
100 #}
101
102
103 1;