mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-04 05:16:45 +00:00
93_FHEM2FHEM.pm: rewrite keepalive (Forum #122805)
git-svn-id: https://svn.fhem.de/fhem/trunk@24944 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2e23d9dfa7
commit
b30d3d29db
@ -416,10 +416,22 @@ sub
|
||||
FHEM2FHEM_keepalive($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
my $ki = AttrVal($hash->{NAME}, "keepaliveInterval", 0);
|
||||
my $name = $hash->{NAME};
|
||||
my $ki = AttrVal($name, "keepaliveInterval", 0);
|
||||
return if(!$ki || !$hash->{TCPDev});
|
||||
syswrite($hash->{TCPDev}, "{undef}\n");
|
||||
InternalTimer(gettimeofday()+$ki, "FHEM2FHEM_keepalive", $hash);
|
||||
|
||||
HttpUtils_Connect({
|
||||
url => "http://$hash->{Host}/", noConn2 => 1,
|
||||
callback=> sub {
|
||||
my ($h, $err, undef) = @_;
|
||||
if($err) {
|
||||
Log3 $name, 4, "$name keepalive: $err";
|
||||
return FHEM2FHEM_Disconnected($hash);
|
||||
}
|
||||
$h->{conn}->close();
|
||||
InternalTimer(gettimeofday()+$ki, "FHEM2FHEM_keepalive", $hash);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user