add an RBN line to progress
[spider.git] / perl / ExtMsg.pm
index 71957817240f3793c229fecc1ba4729eaece1d1e..ffa16bb711e92257ba185aef822b95b00236a480 100644 (file)
@@ -54,11 +54,8 @@ sub enqueue
 sub send_raw
 {
        my ($conn, $msg) = @_;
-    my $sock = $conn->{sock};
-    return unless defined($sock);
-       push (@{$conn->{outqueue}}, $msg);
-       dbg("connect $conn->{cnum}: $msg") if $conn->{state} ne 'C' && isdbg('connect');
-    Msg::set_event_handler ($sock, "write" => sub {$conn->_send(0)});
+       dbg((ref $conn) . " connect $conn->{cnum}: $msg") if $conn->{state} ne 'C' && isdbg('connect');
+       $conn->SUPER::send_raw($msg);
 }
 
 sub echo
@@ -154,54 +151,21 @@ sub to_connected
        $conn->{timeout}->del if $conn->{timeout};
        delete $conn->{timeout};
        $conn->{csort} = $sort;
-       $conn->nolinger unless $conn->ax25;
        &{$conn->{rproc}}($conn, "$dir$call|$sort");
-       $conn->_send_file("$main::data/connected") unless $conn->{outgoing};
+       $conn->_send_file(localdata("connected")) unless $conn->{outgoing};
 }
 
 sub new_client {
+       
        my $server_conn = shift;
-    my $sock = $server_conn->{sock}->accept();
-       if ($sock) {
-               my $conn = $server_conn->new($server_conn->{rproc});
-               $conn->{sock} = $sock;
-               $conn->nolinger;
-               Msg::blocking($sock, 0);
-               $conn->{blocking} = 0;
-               eval {$conn->{peerhost} = $sock->peerhost};
-               if ($@) {
-                       dbg($@) if isdbg('connll');
-                       $conn->disconnect;
-               } else {
-                       eval {$conn->{peerport} = $sock->peerport};
-                       $conn->{peerport} = 0 if $@;
-                       my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost}, $conn->{peerport});
-                       dbg("accept $conn->{cnum} from $conn->{peerhost} $conn->{peerport}") if isdbg('connll');
-                       if ($eproc) {
-                               $conn->{eproc} = $eproc;
-                               Msg::set_event_handler ($sock, "error" => $eproc);
-                       }
-                       if ($rproc) {
-                               $conn->{rproc} = $rproc;
-                               my $callback = sub {$conn->_rcv};
-                               Msg::set_event_handler ($sock, "read" => $callback);
-                               # send login prompt
-                               $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");
-                               $conn->_send_file("$main::data/issue");
-                               $conn->send_raw("login: ");
-                               $conn->_dotimeout(60);
-                               $conn->{echo} = 1;
-                       } else { 
-                               &{$conn->{eproc}}() if $conn->{eproc};
-                               $conn->disconnect();
-                       }
-               }
-       } else {
-               dbg("ExtMsg: error on accept ($!)") if isdbg('err');
-       }
+       my $client = shift;
+       my $conn = $server_conn->SUPER::new_client($client);
+       # send login prompt
+       $conn->{state} = 'WL';
+       $conn->_send_file(localdata("issue"));
+       $conn->send_raw("login: ");
+       $conn->_dotimeout(60);
+       $conn->{echo} = 1;
 }
 
 sub start_connect
@@ -362,6 +326,7 @@ sub _doclient
        $conn->conns($call);
        $conn->{csort} = $f[1] if $f[1];
        $conn->{state} = 'C';
+       eval {$conn->{peerhost} = $conn->{sock}->handle->peerhost} unless $conn->ax25;
        &{$conn->{rproc}}($conn, "O$call|$conn->{csort}");
        delete $conn->{cmd};
        $conn->{timeout}->del if $conn->{timeout};