- my($conn, $rs, $event) = @_;
- my $rec = $rs->record(0);
- print $conn->option("host"), ": got 0: $rec = '", $rec->render(), "'\n";
+ my($conn, $state, $rs, $event) = @_;
+
+ {
+ # Sanity-checking assertions. These should be impossible
+ my $ns = $state->{next_to_show};
+ my $nf = $state->{next_to_fetch};
+ if ($ns > $nf) {
+ die "next_to_show > next_to_fetch ($ns > $nf)";
+ } elsif ($ns == $nf) {
+ die "next_to_show == next_to_fetch ($ns)";
+ }
+ }
+
+ my $i = $state->{next_to_show}++;
+ my $rec = $rs->record($i);
+ print $conn->option("host"), ": record $i is ", render_record($rec), "\n";
+ request_record($conn, $rs, $state);