X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProtout.pm;h=786d78c0f8d08c8be09704d6fdbd81bd8bd06567;hb=febdc9bd8f6cd065d217ba089fab4361e9980f35;hp=86ab0e86562269b4dfe47b8317a7b646fb432a31;hpb=9630876e30f288575b5343ec2d0b5bb6d67f92cc;p=spider.git diff --git a/perl/DXProtout.pm b/perl/DXProtout.pm index 86ab0e86..786d78c0 100644 --- a/perl/DXProtout.pm +++ b/perl/DXProtout.pm @@ -67,42 +67,48 @@ sub pc12 # # add one or more users (I am expecting references that have 'call', -# 'confmode' & 'here' method) +# 'conf' & 'here' method) # # this will create a list of PC16 with up pc16_max_users in each # called $self->pc16(..) # sub pc16 { - my $self = shift; + my $node = shift; + my $ncall = $node->call; my @out; - foreach (@_) { - my $str = "PC16^$self->{call}"; - my $i; - - for ($i = 0; @_ > 0 && $i < $DXProt::pc16_max_users; $i++) { + my $str = "PC16^$ncall"; + while (@_) { + for ( ; @_ && length $str < 200; ) { my $ref = shift; - $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here; + $str .= sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here; } $str .= sprintf "^%s^", get_hops(16); push @out, $str; } - return (@out); + return @out; } # remove a local user sub pc17 { - my ($self, $ref) = @_; - my $hops = get_hops(17); - return "PC17^$ref->{call}^$self->{call}^$hops^"; + my @out; + while (@_) { + my $node = shift; + my $ref = shift; + my $hops = get_hops(17); + my $ncall = $node->call; + my $ucall = $ref->call; + push @out, "PC17^$ucall^$ncall^$hops^"; + } + return @out; } # Request init string sub pc18 { - return "PC18^DXSpider Version $main::version Build $main::build^$DXProt::myprot_version^"; + return "PC18^DXSpider Version: $main::version Build: $main::build^$DXProt::myprot_version^"; } # @@ -110,18 +116,17 @@ sub pc18 # sub pc19 { - my $self = shift; my @out; - while (@_) { + while(@_) { my $str = "PC19"; - my $i; - - for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) { + for (; @_ && length $str < 200;) { my $ref = shift; - my $here = $ref->{here} ? '1' : '0'; - my $confmode = $ref->{confmode} ? '1' : '0'; - $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}"; + my $call = $ref->call; + my $here = $ref->here; + my $conf = $ref->conf; + my $version = $ref->version; + $str .= "^$here^$call^$conf^$version"; } $str .= sprintf "^%s^", get_hops(19); push @out, $str; @@ -138,10 +143,14 @@ sub pc20 # delete a node sub pc21 { - my ($call, $reason) = @_; - my $hops = get_hops(21); - $reason = "Gone." if !$reason; - return "PC21^$call^$reason^$hops^"; + my @out; + while (@_) { + my $node = shift; + my $hops = get_hops(21); + my $call = $node->call; + push @out, "PC21^$call^Gone^$hops^"; + } + return @out; } # end of init phase @@ -243,8 +252,7 @@ sub pc35 # send all the DX clusters I reckon are connected sub pc38 { - my @nodes = map { ($_->dxchan && $_->dxchan->isolate) ? () : $_->call } DXNode->get_all(); - return "PC38^" . join(',', @nodes) . "^~"; + return join '^', "PC38", map {$_->call} Route::Node::get_all(); } # tell the local node to discconnect