DevIo.pm: ad DevIo_Ping, output ping/pong data (Forum #109910)

git-svn-id: https://svn.fhem.de/fhem/trunk@22104 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2020-06-03 18:47:13 +00:00
parent e5f2d2559a
commit 5b0db7a773

View File

@@ -162,6 +162,14 @@ my %wsCloseCode = (
1011=>"unexpected condition"
);
sub
DevIo_Ping($;$)
{
my ($hash,$msg) = @_;
$msg="" if(!defined($msg));
syswrite($hash->{TCPDev}, DevIo_MaskWS(0x9, $msg)) if($hash->{WEBSOCKET});
}
sub
DevIo_DecodeWS($$)
{
@@ -216,8 +224,14 @@ DevIo_DecodeWS($$)
} elsif($op == 9) { # Ping
syswrite($hash->{TCPDev}, DevIo_MaskWS(0xA, $data)); # Pong
Log3 $hash, 5, "Websocket ping: $data" if($data);
$hash->{".WSBUF"} = substr($data, 2);
return DevIo_DecodeWS($hash, "");
} elsif($op == 10) { # Pong
Log3 $hash, 5, "Websocket pong: $data" if($data);
return ""
}
return $data;