1 # $Id: Pod.pm,v 1.3 2006-05-09 16:31:05 mike Exp $
14 $pod = new ZOOM::Pod("bagel.indexdata.com/gils",
15 "bagel.indexdata.com/marc");
16 $pod->callback(ZOOM::Event::RECV_SEARCH, \&completed_search);
17 $pod->callback(ZOOM::Event::RECV_RECORD, \&got_record);
18 $pod->search_pqf("the");
20 die "$pod->wait() failed with error $err" if $err;
22 sub completed_search {
24 print $conn->option("host"), ": found ", $rs->size(), " records\n";
25 $rs->record(0); # Queues a request for the record
31 $rec = $rs->record(0);
32 print $conn->option("host"), ": got $rec = '", $rec->render(), "'\n";
39 # Just register the name
40 ZOOM::Log::mask_str("pod");
47 my @state; # Hashrefs with application state associated with connections
48 foreach my $conn (@conn) {
50 $conn = new ZOOM::Connection($conn, 0, async => 1);
65 my($key, $value) = @_;
67 foreach my $conn (@{ $this->{conn} }) {
68 $conn->option($key, $value);
74 my($event, $sub) = @_;
76 my $old = $this->{callback}->{$event};
77 $this->{callback}->{$event} = $sub
87 foreach my $i (0..@{ $this->{conn} }-1) {
88 $this->{rs}->[$i] = $this->{conn}->[$i]->search_pqf($pqf);
96 while ((my $i = ZOOM::event($this->{conn})) != 0) {
97 my $conn = $this->{conn}->[$i-1];
98 my $ev = $conn->last_event();
99 ZOOM::Log::log("pod", "connection ", $i-1, ": ", ZOOM::event_str($ev));
100 my $sub = $this->{callback}->{$ev};
102 $res = &$sub($conn, $this->{state}->[$i-1],
103 $this->{rs}->[$i-1], $ev);