Use ZEND only for callbacks, rather than RECV_*
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Ping.pm
1 # $Id: Ping.pm,v 1.20 2007-02-23 15:03:44 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 use ZOOM::IRSpy::Utils qw(isodate);
15
16
17 sub start {
18     my $class = shift();
19     my($conn) = @_;
20
21     $conn->irspy_connect(undef, {},
22                          ZOOM::Event::ZEND, \&connected,
23                          exception => \&not_connected);
24 }
25
26
27 sub connected { maybe_connected(@_, 1) }
28 sub not_connected { maybe_connected(@_, 0) }
29
30 sub maybe_connected {
31     my($conn, $task, $__UNUSED_udata, $event, $ok) = @_;
32
33     $conn->log("irspy_test", ($ok ? "" : "not "), "connected");
34     my $rec = $conn->record();
35     $rec->append_entry("irspy:status", "<irspy:probe ok='$ok'>" .
36                        isodate(time()) . "</irspy:probe>");
37
38     if ($ok) {
39         foreach my $opt (qw(search present delSet resourceReport
40                             triggerResourceCtrl resourceCtrl
41                             accessCtrl scan sort extendedServices
42                             level_1Segmentation level_2Segmentation
43                             concurrentOperations namedResultSets
44                             encapsulation resultCount negotiationModel
45                             duplicationDetection queryType104
46                             pQESCorrection stringSchema)) {
47             #print STDERR "\$conn->option('init_opt_$opt') = '", $conn->option("init_opt_$opt"), "'\n";
48             $conn->record()->store_result('init_opt', option => $opt)
49                 if $conn->option("init_opt_$opt");
50         }
51
52         foreach my $opt (qw(serverImplementationId
53                             serverImplementationName
54                             serverImplementationVersion)) {
55             $conn->record()->store_result($opt, value => $conn->option($opt));
56         }
57     }
58
59
60     return $ok ? ZOOM::IRSpy::Status::TEST_GOOD :
61                  ZOOM::IRSpy::Status::TEST_BAD;
62 }
63
64
65 1;