X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FThingy%2FPing.pm;h=d3fa90f401286f8440ef81328892a304fb6fc3be;hb=80c59c4d9c407fd5021e693cf4ed5d1192b12d6c;hp=88e68a851a1107bd53f75719cf01930d859c0333;hpb=f846b4d17b1c1eb4158b2b9dae67c7c036971011;p=spider.git diff --git a/perl/Thingy/Ping.pm b/perl/Thingy/Ping.pm index 88e68a85..d3fa90f4 100644 --- a/perl/Thingy/Ping.pm +++ b/perl/Thingy/Ping.pm @@ -22,16 +22,18 @@ use Spot; use Time::HiRes qw(gettimeofday tv_interval); -use vars qw(@ISA %ping); +use vars qw(@ISA %ping $ping_ttl); @ISA = qw(Thingy); my $id; +$ping_ttl = 300; # default ping ttl + sub gen_Aranea { my $thing = shift; unless ($thing->{Aranea}) { - $thing->{Aranea} = Aranea::genmsg($thing, qw(id out)); + $thing->{Aranea} = Aranea::genmsg($thing, qw(id out o)); } return $thing->{Aranea}; } @@ -53,10 +55,13 @@ sub gen_DXProt # {user} as well as a true user and also it may not # have originated here. - my $from = $thing->{user} if Route::Node::get($thing->{user}); + my $from = $thing->{o} if $thing->{out}; + $from ||= $thing->{user} if Route::Node::get($thing->{user}); $from ||= $thing->{origin}; - my $to = $thing->{touser} if Route::Node::get($thing->{touser}); + my $to = $thing->{o} unless $thing->{out}; + $to ||= $thing->{touser} if Route::Node::get($thing->{touser}); $to ||= $thing->{group}; + $thing->{DXProt} = DXProt::pc51($to, $from, $thing->{out}); } @@ -67,19 +72,23 @@ sub gen_DXCommandmode { my $thing = shift; my $dxchan = shift; - my $buf; - + my $buf = $dxchan->msg('pingi', ($thing->{user} || $thing->{origin}), $thing->{ft}, $thing->{fave}); return $buf; } +# called with the dxchan, line and the split out arguments sub from_DXProt { - my $thing = ref $_[0] ? shift : $_[0]->SUPER::new(); - - while (@_) { - my $k = shift; - $thing->{$k} = shift; - } + my $thing = ref $_[0] ? shift : $_[0]->SUPER::new(origin=>$main::mycall); + my $dxchan = shift; + $thing->{DXProt} = shift; + shift; # PC51 + $thing->{group} = shift; # to call + my $from = shift; + $thing->{out} = shift; # 1 = ping, 0 = pong; + $thing->{user} = $dxchan->{call}; + $thing->{o} = $from unless $from eq $dxchan->{call}; + $thing->remember if $thing->{out} && $thing->{group} ne $main::mycall; return $thing; } @@ -94,6 +103,7 @@ sub handle 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 { @@ -122,11 +132,9 @@ sub handle $tochan->{nopings} = $nopings; # pump up the timer } if (my $dxc = DXChannel::get($ref->{user} || $ref->{origin})) { - if ($dxc->is_user) { - my $s = sprintf "%.2f", $t; - my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t; - $dxc->send($dxc->msg('pingi', ($ref->{touser} || $ref->{group}), $s, $ave)) - } + $thing->{ft} = sprintf "%.2f", $t; + $thing->{fave} = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t; + $thing->send($dxc); } delete $ping{$ref->{id}}; }