mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
MQTT2_CLIENT: MQTT over websocket Work-In-Progress (Forum #111959)
git-svn-id: https://svn.fhem.de/fhem/trunk@27247 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3d1c9de9aa
commit
a1e696ff09
@ -43,6 +43,7 @@ MQTT2_CLIENT_Initialize($)
|
||||
disable:1,0
|
||||
disabledForIntervals
|
||||
disconnectAfter
|
||||
httpHeader
|
||||
ignoreRegexp
|
||||
lwt
|
||||
lwtRetain
|
||||
@ -107,6 +108,10 @@ MQTT2_CLIENT_connect($)
|
||||
$hash->{connecting} = 1 if($disco && !$hash->{connecting});
|
||||
$hash->{nextOpenDelay} = 5;
|
||||
$hash->{BUF}="";
|
||||
if($hash->{DeviceName} =~ m/^wss?:/) {
|
||||
$hash->{binary} = 1;
|
||||
$hash->{header}{"Sec-WebSocket-Protocol"} = "mqtt";
|
||||
}
|
||||
return DevIo_OpenDev($hash, $disco, "MQTT2_CLIENT_doinit", sub(){})
|
||||
if($hash->{connecting});
|
||||
}
|
||||
@ -314,6 +319,14 @@ MQTT2_CLIENT_Attr(@)
|
||||
}
|
||||
}
|
||||
|
||||
if($attrName eq "httpHeader") {
|
||||
$hash->{header} = {};
|
||||
for my $kv (split(" ",$param[0])) {
|
||||
my ($k, $v) = split(":", $kv, 2);
|
||||
$hash->{header}{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
my %h = (clientId=>1,lwt=>1,lwtRetain=>1,subscriptions=>1,SSL=>1,username=>1);
|
||||
if($init_done && $h{$attrName}) {
|
||||
delete($hash->{authError});
|
||||
@ -874,6 +887,13 @@ MQTT2_CLIENT_feedTheList($$$)
|
||||
inactivity, and will be automatically reopened when sending a command.
|
||||
</li><br>
|
||||
|
||||
<a id="MQTT2_CLIENT-attr-httpHeader"></a>
|
||||
<li>header<br>
|
||||
a list of space separated tuples of key:value, used to set the HTTP
|
||||
header when MQTT is used over websocket.
|
||||
</li><br>
|
||||
|
||||
|
||||
<a id="MQTT2_CLIENT-attr-ignoreRegexp"></a>
|
||||
<li>ignoreRegexp<br>
|
||||
if $topic:$message matches ignoreRegexp, then it will be silently ignored.
|
||||
|
@ -280,8 +280,9 @@ DevIo_SimpleWrite($$$;$)
|
||||
|
||||
} elsif($hash->{TCPDev}) {
|
||||
if($hash->{WEBSOCKET}) {
|
||||
$msg = Encode::encode('UTF-8', $msg) if($unicodeEncoding && !$hash->{binary});
|
||||
$msg = DevIo_MaskWS($hash->{binary} ? 0x2:0x1, $msg)
|
||||
$msg = Encode::encode('UTF-8', $msg)
|
||||
if($unicodeEncoding && !$hash->{binary});
|
||||
$msg = DevIo_MaskWS($hash->{binary} ? 0x2:0x1, $msg);
|
||||
}
|
||||
syswrite($hash->{TCPDev}, $msg);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user