- my $r = shift @$ref;
- my $dxchan = DXChannel->get($r->{call});
- $dxchan->send($dxchan->msg('pingi', $field[2], atime($main::systime), $main::systime - $r->{t})) if $dxchan;
+ my $tochan = DXChannel->get($field[2]);
+ while (@$ref) {
+ my $r = shift @$ref;
+ my $dxchan = DXChannel->get($r->{call});
+ next unless $dxchan;
+ my $t = tv_interval($r->{t}, [ gettimeofday ]);
+ if ($dxchan->is_user) {
+ my $s = sprintf "%.2f", $t;
+ my $ave = sprintf "%.2f", $tochan ? ($tochan->pingave || $t) : $t;
+ $dxchan->send($dxchan->msg('pingi', $field[2], $s, $ave))
+ } elsif ($dxchan->is_ak1a) {
+ if ($tochan) {
+ $tochan->nopings(3); # pump up the timer
+ push @{$tochan->pingtime}, $t;
+ shift @{$tochan->pingtime} if @{$tochan->pingtime} > 10;
+ my $st;
+ for (@{$tochan->pingtime}) {
+ $st += $_;
+ }
+ $tochan->{pingave} = $st / @{$tochan->pingtime};
+ }
+ }
+ }