+ # is it for us?
+ if ($thing->{group} eq $main::mycall) {
+ if ($thing->{out} == 1) {
+ my $repthing = $thing->new_reply;
+ $repthing->{out} = 0;
+ $repthing->{id} = $thing->{id};
+ $repthing->{o} = $thing->{o} if $thing->{o};
+ $repthing->send($dxchan) if $repthing;
+ } else {
+
+ # it's a reply, look in the ping list for this one
+ my $ref;
+ $ref = $ping{$thing->{id}} if exists $thing->{id};
+ $ref = find(($thing->{user}||$thing->{origin}), ($thing->{touser}||$thing->{group})) unless $ref;
+ if ($ref) {
+ my $t = tv_interval($ref->{t}, [ gettimeofday ]);
+ my $tochan = DXChannel::get($ref->{touser} || $ref->{group});
+ if ($tochan) {
+ my $nopings = $tochan->user->nopings || $DXProt::obscount;
+ push @{$tochan->{pingtime}}, $t;
+ shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
+
+ # cope with a missed ping, this means you must set the pingint large enough
+ if ($t > $tochan->{pingint} && $t < 2 * $tochan->{pingint} ) {
+ $t -= $tochan->{pingint};
+ }
+
+ # calc smoothed RTT a la TCP
+ if (@{$tochan->{pingtime}} == 1) {
+ $tochan->{pingave} = $t;
+ } else {
+ $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 6);
+ }
+ $tochan->{nopings} = $nopings; # pump up the timer
+ }
+ if (my $dxc = DXChannel::get($ref->{user} || $ref->{origin})) {
+ $thing->{ft} = sprintf "%.2f", $t;
+ $thing->{fave} = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
+ $thing->send($dxc);
+ }
+ delete $ping{$ref->{id}};
+ }
+ }
+ } else {
+ $thing->broadcast($dxchan);
+ }