X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=perl%2FDXChannel.pm;h=17f34919e7eb970f4eef85a2cc893e3dd95469d2;hb=29ec5bb85c591182dd868e7a3d87f510d7b47e9b;hp=8b71dbff499d7946a83378b2938f6c54f6ea41c4;hpb=8e45a3dac2e136dc0c9d6f1e78f8c048a8d7ba21;p=spider.git diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 8b71dbff..17f34919 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -87,6 +87,7 @@ use vars qw(%channels %valid); pingave => '0,Ping ave time', logininfo => '9,Login info req,yesno', talklist => '0,Talk List,parray', + node => '5,Node data', ); # object destruction @@ -106,6 +107,7 @@ sub DESTROY undef $self->{inwwvfilter}; undef $self->{inspotfilter}; undef $self->{passwd}; + undef $self->{node}; } # create a new channel object [$obj = DXChannel->new($call, $msg_conn_obj, $user_obj)] @@ -158,12 +160,11 @@ sub get_all # # gimme all the ak1a nodes # -sub get_all_ak1a +sub get_all_nodes { - my @list = DXChannel->get_all(); my $ref; my @out; - foreach $ref (@list) { + foreach $ref (values %channels) { push @out, $ref if $ref->is_node; } return @out; @@ -172,10 +173,9 @@ sub get_all_ak1a # return a list of all users sub get_all_users { - my @list = DXChannel->get_all(); my $ref; my @out; - foreach $ref (@list) { + foreach $ref (values %channels) { push @out, $ref if $ref->is_user; } return @out; @@ -184,11 +184,10 @@ sub get_all_users # return a list of all user callsigns sub get_all_user_calls { - my @list = DXChannel->get_all(); my $ref; my @out; - foreach $ref (@list) { - push @out, $ref->call if $ref->is_user; + foreach $ref (values %channels) { + push @out, $ref->{call} if $ref->is_user; } return @out; } @@ -286,7 +285,7 @@ sub send_now my $call = $self->{call}; for (@_) { - chomp; +# chomp; my @lines = split /\n/; for (@lines) { $conn->send_now("$sort$call|$_"); @@ -307,7 +306,7 @@ sub send # this is always later and always data my $call = $self->{call}; for (@_) { - chomp; +# chomp; my @lines = split /\n/; for (@lines) { $conn->send_later("D$call|$_"); @@ -466,8 +465,13 @@ sub AUTOLOAD $name =~ s/.*:://o; confess "Non-existant field '$AUTOLOAD'" if !$valid{$name}; - @_ ? $self->{$name} = shift : $self->{$name} ; + + # this clever line of code creates a subroutine which takes over from autoload + # from OO Perl - Conway + *{$AUTOLOAD} = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ; + @_ ? $self->{$name} = shift : $self->{$name} ; } + 1; __END__;