X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXChannel.pm;h=e72be8020ae7c3c49740d90df4c48555702b23c5;hb=1f9712e804601df2e26f70ef88410c94546f44af;hp=7319344caeb51fa8bda7770f5c12f397f685e7c6;hpb=cce161221036760959ff1d0b7628a55942bf558a;p=spider.git diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 7319344c..e72be802 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -51,6 +51,7 @@ use vars qw(%channels %valid); consort => '9,Connection Type', 'sort' => '9,Type of Channel', wwv => '0,Want WWV,yesno', + wx => '0,Want WX,yesno', talk => '0,Want Talk,yesno', ann => '0,Want Announce,yesno', here => '0,Here?,yesno', @@ -68,6 +69,7 @@ use vars qw(%channels %valid); pagedata => '9,Page Data Store', group => '0,Access Group,parray', # used to create a group of users/nodes for some purpose or other isolate => '9,Isolate network,yesno', + delayed => '9,Delayed messages,parray', ); # create a new channel object [$obj = DXChannel->new($call, $msg_conn_obj, $user_obj)] @@ -156,12 +158,11 @@ sub send_now my $conn = $self->{conn}; my $sort = shift; my $call = $self->{call}; - my $line; - foreach $line (@_) { - chomp $line; - $conn->send_now("$sort$call|$line") if $conn; - dbg('chan', "-> $sort $call $line") if $conn; + for (@_) { + chomp; + $conn->send_now("$sort$call|$_") if $conn; + dbg('chan', "-> $sort $call $_") if $conn; } $self->{t} = time; } @@ -174,12 +175,11 @@ sub send # this is always later and always data my $self = shift; my $conn = $self->{conn}; my $call = $self->{call}; - my $line; - foreach $line (@_) { - chomp $line; - $conn->send_later("D$call|$line") if $conn; - dbg('chan', "-> D $call $line") if $conn; + for (@_) { + chomp; + $conn->send_later("D$call|$_") if $conn; + dbg('chan', "-> D $call $_") if $conn; } $self->{t} = time; } @@ -205,6 +205,16 @@ sub msg return DXM::msg($self->{lang}, @_); } +# stick a broadcast on the delayed queue +sub delay +{ + my $self = shift; + my $s = shift; + + $self->{delayed} = [] unless $self->{delayed}; + push @{$self->{delayed}}, $s; +} + # change the state of the channel - lots of scope for debugging here :-) sub state { @@ -212,7 +222,16 @@ sub state if (@_) { $self->{oldstate} = $self->{state}; $self->{state} = shift; + $self->{func} = '' unless defined $self->{func}; dbg('state', "$self->{call} channel func $self->{func} state $self->{oldstate} -> $self->{state}\n"); + + # if there is any queued up broadcasts then splurge them out here + if ($self->{delayed} && ($self->{state} eq 'prompt' || $self->{state} eq 'convers')) { + for (@{$self->{delayed}}) { + $self->send($_); + } + delete $self->{delayed}; + } } return $self->{state}; } @@ -232,6 +251,22 @@ sub disconnect $self->del(); } +# +# just close all the socket connections down without any fiddling about, cleaning, being +# nice to other processes and otherwise telling them what is going on. +# +# This is for the benefit of forked processes to prepare for starting new programs, they +# don't want or need all this baggage. +# + +sub closeall +{ + my $ref; + foreach $ref (values %channels) { + $ref->{conn}->disconnect() if $ref->{conn}; + } +} + # various access routines #