X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCron.pm;h=39776dccde4094ccfe6814568c185e58ff77c187;hb=58234eafde7d75028574ae6aa519d2197120c558;hp=1c698f751e5b045808c1ead66791125a848924c2;hpb=15ee0303d77c205e68144dfd8d8a4e0110bbe5ea;p=spider.git diff --git a/perl/DXCron.pm b/perl/DXCron.pm index 1c698f75..39776dcc 100644 --- a/perl/DXCron.pm +++ b/perl/DXCron.pm @@ -175,32 +175,43 @@ sub connected sub present { my $call = uc shift; - return DXCluster->get_exact($call); + return Route::get($call); } # is it remotely connected anywhere (ignoring SSIDS)? sub presentish { my $call = uc shift; - return DXCluster->get($call); + my $c = Route::get($call); + unless ($c) { + for (1..15) { + $c = Route::get("$call-$_"); + last if $c; + } + } + return $c; } # is it remotely connected anywhere (with exact callsign) and on node? sub present_on { my $call = uc shift; - my $node = uc shift; - my $ref = DXCluster->get_exact($call); - return ($ref && $ref->mynode) ? $ref->mynode->call eq $node : undef; + my $ncall = uc shift; + my $node = Route::Node::get($ncall); + return ($node) ? grep $call eq $_, $node->users : undef; } -# is it remotely connected anywhere (ignoring SSIDS) and on node? +# is it remotely connected (ignoring SSIDS) and on node? sub presentish_on { my $call = uc shift; - my $node = uc shift; - my $ref = DXCluster->get($call); - return ($ref && $ref->mynode) ? $ref->mynode->call eq $node : undef; + my $ncall = uc shift; + my $node = Route::Node::get($ncall); + my $present; + if ($node) { + $present = grep {/^$call/ } $node->users; + } + return $present; } # last time this thing was connected @@ -215,26 +226,16 @@ sub last_connect # disconnect a locally connected thing sub disconnect { - my $call = uc shift; - my $dxchan = DXChannel->get($call); - $dxchan->disconnect if $dxchan; + my $call = shift; + run_cmd("disconnect $call"); } # start a connect process off sub start_connect { - my $call = uc shift; - my $lccall = lc $call; - - if (Msg->conns($call)) { - dbg('cron', "Connect not started, outstanding connect to $call"); - return; - } - if (-e "$main::root/connect/$lccall") { - ExtMsg::start_connect($call, "$main::root/connect/$lccall"); - } else { - dbg('err', "Cannot find connect script for $lccall"); - } + my $call = shift; + # connecting is now done in one place - Yeah! + run_cmd("connect $call"); } # spawn any old job off @@ -252,7 +253,7 @@ sub spawn for (@main::listeners) { $_->close_server; } - unless ($^O =~ /^MS/) { + unless ($main::is_win) { $SIG{HUP} = 'IGNORE'; $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT'; alarm(0); @@ -275,11 +276,22 @@ sub rcmd my $line = shift; # can we see it? Is it a node? - my $noderef = DXCluster->get_exact($call); - return if !$noderef || !$noderef->pcversion; + my $noderef = Route::Node::get($call); + return unless $noderef && $noderef->version; # send it DXProt::addrcmd($DXProt::me, $call, $line); } + +sub run_cmd +{ + my $line = shift; + my @in = DXCommandmode::run_cmd($DXProt::me, $line); + dbg('cron', "cmd run: $line"); + for (@in) { + s/\s*$//og; + dbg('cron', "cmd out: $_"); + } +} 1; __END__