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