X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=blobdiff_plain;f=perl%2FDXChannel.pm;h=6a867bb95185896d9c726ba4e15c3e99577a6b01;hp=d4b20a2bedffe94f48dc1ab40e5fd83215259133;hb=60c0ea1747bc8ad95e531d29025f7bcee4fd10c1;hpb=0017002e2dc438d49fcc090dc99b6d22f7037aa7 diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index d4b20a2b..6a867bb9 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -10,6 +10,8 @@ package DXChannel; require Exporter; @ISA = qw(Exporter); +use Msg; + %connects = undef; # create a new connection object [$obj = Connect->new($call, $msg_conn_obj, $user_obj)] @@ -61,5 +63,51 @@ sub del delete $connects{$self->{call}}; } + +# handle out going messages +sub send_now +{ + my $self = shift; + my $sort = shift; + my $call = $self->{call}; + my $conn = $self->{conn}; + my $line; + + foreach $line (@_) { + print DEBUG "$t > $sort $call $line\n" if defined DEBUG; + print "> $sort $call $line\n"; + $conn->send_now("$sort$call|$line"); + } +} + +sub send_later +{ + my $self = shift; + my $sort = shift; + my $call = $self->{call}; + my $conn = $self->{conn}; + my $line; + + foreach $line (@_) { + print DEBUG "$t > $sort $call $line\n" if defined DEBUG; + print "> $sort $call $line\n"; + $conn->send_later("$sort$call|$line"); + } +} + +# send a file (always later) +sub send_file +{ + my ($self, $fn) = @_; + my $call = $self->{call}; + my $conn = $self->{conn}; + my @buf; + + open(F, $fn) or die "can't open $fn for sending file ($!)"; + @buf = ; + close(F); + $self->send_later('D', @buf); +} + 1; __END__;