DevIo.pm: add close Codes (Forum #109910)
git-svn-id: https://svn.fhem.de/fhem/trunk@22103 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -137,10 +137,9 @@ DevIo_MaskWS($$)
|
|||||||
$lb = chr(0x80+$len);
|
$lb = chr(0x80+$len);
|
||||||
} else {
|
} else {
|
||||||
if ($len < 65536) {
|
if ($len < 65536) {
|
||||||
$lb = chr(0x8E) . pack('n', $len);
|
$lb = chr(0xFE).pack('n',$len);
|
||||||
} else {
|
} else {
|
||||||
$lb = chr(0x8F) . chr(0x00) . chr(0x00) .
|
$lb = chr(0xFF).chr(0x00).chr(0x00).chr(0x00).chr(0x00).pack('N',$len);
|
||||||
chr(0x00) . chr(0x00) . pack('N', $len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +150,17 @@ DevIo_MaskWS($$)
|
|||||||
return $opcode.$lb.$mask.$msg;
|
return $opcode.$lb.$mask.$msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my %wsCloseCode = (
|
||||||
|
1000=>"normal",
|
||||||
|
1001=>"going away",
|
||||||
|
1002=>"protocol error",
|
||||||
|
1003=>"cannot accept datatype",
|
||||||
|
1007=>"inconsistent data",
|
||||||
|
1008=>"policy violation",
|
||||||
|
1009=>"too big",
|
||||||
|
1010=>"missing extension",
|
||||||
|
1011=>"unexpected condition"
|
||||||
|
);
|
||||||
|
|
||||||
sub
|
sub
|
||||||
DevIo_DecodeWS($$)
|
DevIo_DecodeWS($$)
|
||||||
@@ -195,7 +205,11 @@ DevIo_DecodeWS($$)
|
|||||||
|
|
||||||
# $op: 0=>Continuation, 1=>Text, 2=>Binary, 8=>Close, 9=>Ping, 10=>Pong
|
# $op: 0=>Continuation, 1=>Text, 2=>Binary, 8=>Close, 9=>Ping, 10=>Pong
|
||||||
Log3 $hash, 5, "Websocket msg: OP:$op LEN:$len MASK:$mask FIN:$fin";
|
Log3 $hash, 5, "Websocket msg: OP:$op LEN:$len MASK:$mask FIN:$fin";
|
||||||
if($op == 8) { # Close, Normal, empty mask. #104718
|
if($op == 8) { # Close
|
||||||
|
my $clCode = unpack("n", substr($data,0,2));
|
||||||
|
$clCode = "$clCode ($wsCloseCode{$clCode})" if($wsCloseCode{$clCode});
|
||||||
|
$clCode .= " ".substr($data, 2) if($len > 2);
|
||||||
|
Log3 $hash, 5, "Websocket close, reason: $clCode";
|
||||||
syswrite($hash->{TCPDev}, DevIo_MaskWS(0x8,$data));
|
syswrite($hash->{TCPDev}, DevIo_MaskWS(0x8,$data));
|
||||||
DevIo_CloseDev($hash);
|
DevIo_CloseDev($hash);
|
||||||
return undef;
|
return undef;
|
||||||
|
|||||||
Reference in New Issue
Block a user