# because I have the 'power of perl' available that avoids me getting
# terminally bored sorting out other people's sloppyness.
#
-# $Id$
+#
#
# Copyright (c) 2001 - Dirk Koopman G1TLH
#
use DXDebug;
use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lastytime
- $lasthtime $ypolltime $hpolltime %circuit $total_in $total_out);
+ $lasthtime $ypolltime $hpolltime %circuit $total_in $total_out
+ $lastconnect $connectinterval);
@ISA = qw(Msg ExtMsg);
$sock = undef;
$hpolltime = 300 unless defined $hpolltime;
%circuit = ();
$total_in = $total_out = 0;
-
-use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
+$lastconnect = 0;
+$connectinterval = 30;
sub init
{
$rproc = shift;
finish();
+
dbg("AGW initialising and connecting to $addr/$port ...");
$sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>15);
+ $lastconnect = $main::systime;
unless ($sock) {
dbg("Cannot connect to AGW Engine at $addr/$port $!");
return;
Msg->sleep(2);
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
$sock->close;
+ $lastconnect = $main::systime;
}
}
+sub login
+{
+ goto &main::login; # save some writing, this was the default
+}
+
sub active
{
return $sock;
&{$_->{eproc}}() if $_->{eproc};
$_->disconnect;
}
+ $lastconnect = $main::systime;
}
sub _decode
sub process
{
+ # try to reconnect to AGW if we could not previously or there was an error
+ if ($enable && !$sock && ($lastconnect + $connectinterval) >= $main::systime) {
+ init();
+ }
return unless $sock;
+
if ($ypolltime && $main::systime - $lastytime >= $ypolltime) {
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i );