X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXChannel.pm;h=7f144d59046848c458dcb3759571b0b24e12ea64;hb=bbcb636f1bc71eb1426685ef64382ea42d27ecfb;hp=a0b09548444a612545fd68c814f67cc7c9060fa9;hpb=8f58735f5c9c090f2e5e00e05c7ad0834eccb741;p=spider.git diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index a0b09548..7f144d59 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -32,6 +32,7 @@ use DXVars; use DXDebug; use Filter; use Prefix; +use Route; use strict; use vars qw(%channels %valid @ISA $count); @@ -104,6 +105,10 @@ $count = 0; width => '0,Column Width', disconnecting => '9,Disconnecting,yesno', ann_talk => '0,Suppress Talk Anns,yesno', + metric => '1,Route metric', + badcount => '1,Bad Word Count', + edit => '7,Edit Function', + registered => '9,Registered?,yesno', ); use vars qw($VERSION $BRANCH); @@ -500,6 +505,119 @@ sub decode_input return ($sort, $call, $line); } +sub rspfcheck +{ + my ($self, $flag, $node, $user) = @_; + my $nref = Route::Node::get($node); + my $dxchan = $nref->dxchan if $nref; + if ($nref && $dxchan) { + if ($dxchan == $self) { + return 1 unless $user; + my @users = $nref->users; + return 1 if @users == 0 || grep $user eq $_, @users; + dbg("RSPF: $user not on $node") if isdbg('rspf'); + } else { + dbg("RSPF: Shortest path for $node is " . $nref->dxchan->{call}) if isdbg('rspf'); + } + } else { + return 1 if $flag; + dbg("RSPF: required $node not found" ) if isdbg('rspf'); + } + return 0; +} + +# broadcast a message to all clusters taking into account isolation +# [except those mentioned after buffer] +sub broadcast_nodes +{ + my $s = shift; # the line to be rebroadcast + my @except = @_; # to all channels EXCEPT these (dxchannel refs) + my @dxchan = DXChannel::get_all_nodes(); + my $dxchan; + + # send it if it isn't the except list and isn't isolated and still has a hop count + foreach $dxchan (@dxchan) { + next if grep $dxchan == $_, @except; + next if $dxchan == $main::me; + + my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s; # adjust its hop count by node name + + $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit; + } +} + +# broadcast a message to all clusters ignoring isolation +# [except those mentioned after buffer] +sub broadcast_all_nodes +{ + my $s = shift; # the line to be rebroadcast + my @except = @_; # to all channels EXCEPT these (dxchannel refs) + my @dxchan = DXChannel::get_all_nodes(); + my $dxchan; + + # send it if it isn't the except list and isn't isolated and still has a hop count + foreach $dxchan (@dxchan) { + next if grep $dxchan == $_, @except; + next if $dxchan == $main::me; + + my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s; # adjust its hop count by node name + $dxchan->send($routeit); + } +} + +# broadcast to all users +# storing the spot or whatever until it is in a state to receive it +sub broadcast_users +{ + my $s = shift; # the line to be rebroadcast + my $sort = shift; # the type of transmission + my $fref = shift; # a reference to an object to filter on + my @except = @_; # to all channels EXCEPT these (dxchannel refs) + my @dxchan = DXChannel::get_all_users(); + my $dxchan; + my @out; + + foreach $dxchan (@dxchan) { + next if grep $dxchan == $_, @except; + push @out, $dxchan; + } + broadcast_list($s, $sort, $fref, @out); +} + + +# broadcast to a list of users +sub broadcast_list +{ + my $s = shift; + my $sort = shift; + my $fref = shift; + my $dxchan; + + foreach $dxchan (@_) { + my $filter = 1; + next if $dxchan == $main::me; + + if ($sort eq 'dx') { + next unless $dxchan->{dx}; + ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref; + next unless $filter; + } + next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i; + next if $sort eq 'wwv' && !$dxchan->{wwv}; + next if $sort eq 'wcy' && !$dxchan->{wcy}; + next if $sort eq 'wx' && !$dxchan->{wx}; + + $s =~ s/\a//og unless $dxchan->{beep}; + + if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') { + $dxchan->send($s); + } else { + $dxchan->delay($s); + } + } +} + + no strict; sub AUTOLOAD {