X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FExtMsg.pm;h=cd18eb9318039974b7ae7f95101c7c9aeb534f46;hb=0a35942621158fae0bca29f3c70c63a97fc4e691;hp=60566f7ac27fe1f3f85b02945a5bf5c94dbb3cbb;hpb=362f72d428454360344da2bc87377d6cbd5f85aa;p=spider.git diff --git a/perl/ExtMsg.pm b/perl/ExtMsg.pm index 60566f7a..cd18eb93 100644 --- a/perl/ExtMsg.pm +++ b/perl/ExtMsg.pm @@ -29,8 +29,13 @@ sub enqueue { my ($conn, $msg) = @_; unless ($msg =~ /^[ABZ]/) { - if ($msg =~ /^E[-\w]+\|([01])/) { + if ($msg =~ /^E[-\w]+\|([01])/ && $conn->{csort} eq 'telnet') { $conn->{echo} = $1; + if ($1) { +# $conn->send_raw("\xFF\xFC\x01"); + } else { +# $conn->send_raw("\xFF\xFB\x01"); + } } else { $msg =~ s/^[-\w]+\|//; push (@{$conn->{outqueue}}, $msg . $conn->{lineend}); @@ -53,7 +58,8 @@ sub dequeue my $conn = shift; my $msg; - while ($msg = shift @{$conn->{inqueue}}){ + while (@{$conn->{inqueue}}){ + $msg = shift @{$conn->{inqueue}}; dbg('connect', $msg) unless $conn->{state} eq 'C'; $msg =~ s/\xff\xfa.*\xff\xf0|\xff[\xf0-\xfe].//g; # remove telnet options @@ -65,9 +71,8 @@ sub dequeue } elsif ($conn->{state} eq 'WL' ) { $msg = uc $msg; if (is_callsign($msg)) { + &{$conn->{rproc}}($conn, "A$msg|telnet"); _send_file($conn, "$main::data/connected"); - $conn->{call} = $msg; - &{$conn->{rproc}}($conn, "A$conn->{call}|telnet"); $conn->{state} = 'C'; } else { $conn->send_now("Sorry $msg is an invalid callsign"); @@ -76,7 +81,7 @@ sub dequeue } elsif ($conn->{state} eq 'WC') { if (exists $conn->{cmd} && @{$conn->{cmd}}) { $conn->_docmd($msg); - unless ($conn->{state} eq 'WC' && @{$conn->{cmd}}) { + if ($conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}} == 0) { $conn->{state} = 'C'; &{$conn->{rproc}}($conn, "O$conn->{call}|telnet"); delete $conn->{cmd}; @@ -86,8 +91,9 @@ sub dequeue } } if ($conn->{msg} && $conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}}) { + dbg('connect', $conn->{msg}); $conn->_docmd($conn->{msg}); - unless ($conn->{state} eq 'WC' && @{$conn->{cmd}}) { + if ($conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}} == 0) { $conn->{state} = 'C'; &{$conn->{rproc}}($conn, "O$conn->{call}|telnet"); delete $conn->{cmd}; @@ -111,8 +117,9 @@ sub new_client { $conn->{state} = 'WL'; # $conn->send_raw("\xff\xfe\x01\xff\xfc\x01\ff\fd\x22"); # $conn->send_raw("\xff\xfa\x22\x01\x01\xff\xf0"); +# $conn->send_raw("\xFF\xFC\x01"); _send_file($conn, "$main::data/issue"); - $conn->send_raw("Login: "); + $conn->send_raw("login: "); } else { $conn->disconnect(); } @@ -123,12 +130,11 @@ sub start_connect my $call = shift; my $fn = shift; my $conn = ExtMsg->new(\&main::rec); - $conn->{call} = $call; + $conn->conns($call); my $f = new IO::File $fn; push @{$conn->{cmd}}, <$f>; $f->close; - push @main::outstanding_connects, {call => $call, conn => $conn}; $conn->_dotimeout($deftimeout); $conn->_docmd; } @@ -163,9 +169,6 @@ sub _docmd } last if $conn->{state} eq 'E'; } - unless (exists $conn->{cmd} && @{$conn->{cmd}}) { - @main::outstanding_connects = grep {$_->{call} ne $conn->{call}} @main::outstanding_connects; - } } sub _doconnect @@ -253,7 +256,6 @@ sub _timeout my $conn = shift; dbg('connect', "timed out after $conn->{timeval} seconds"); $conn->disconnect; - @main::outstanding_connects = grep {$_->{call} ne $conn->{call}} @main::outstanding_connects; } # handle callsign and connection type firtling @@ -264,6 +266,10 @@ sub _doclient my @f = split /\s+/, $line; $conn->{call} = uc $f[0] if $f[0]; $conn->{csort} = $f[1] if $f[1]; + $conn->{state} = 'C'; + &{$conn->{rproc}}($conn, "O$conn->{call}|telnet"); + delete $conn->{cmd}; + $conn->{timeout}->del_timer if $conn->{timeout}; } sub _send_file @@ -276,7 +282,7 @@ sub _send_file if ($f) { while (<$f>) { chomp; - $conn->send_later($_); + $conn->send_raw($_ . $conn->{lineend}); } $f->close; }