01_FHEMWEB.pm: enable more precise JavaScript client notification (Forum #43945)

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@9867 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2015-11-12 16:41:48 +00:00
parent f33edf5c63
commit 87570522b7
2 changed files with 6 additions and 2 deletions

View File

@@ -2409,8 +2409,10 @@ FW_Notify($$)
if($dn eq $ntfy->{SNAME} && if($dn eq $ntfy->{SNAME} &&
$dev->{CHANGED} && $dev->{CHANGED} &&
$dev->{CHANGED}->[0] =~ m/^JS:(.*)$/) { $dev->{CHANGED}->[0] =~ m/^JS(#([^:]*))?:(.*)$/) {
my $data = FW_longpollInfo($h->{fmt}, "#FHEMWEB:$ntfy->{NAME}",$1,""); my $data = $3;
return if( $2 && $ntfy->{PEER} !~ m/$2/ );
$data = FW_longpollInfo($h->{fmt}, "#FHEMWEB:$ntfy->{NAME}",$data,"");
addToWritebuffer($ntfy, $data."\n"); addToWritebuffer($ntfy, $data."\n");
return; return;
} }

View File

@@ -113,6 +113,8 @@ TcpServer_Accept($$)
my %nhash; my %nhash;
$nhash{NR} = $devcount++; $nhash{NR} = $devcount++;
$nhash{NAME} = $cname; $nhash{NAME} = $cname;
$nhash{PEER} = $caddr;
$nhash{PORT} = $port;
$nhash{FD} = $clientinfo[0]->fileno(); $nhash{FD} = $clientinfo[0]->fileno();
$nhash{CD} = $clientinfo[0]; # sysread / close won't work on fileno $nhash{CD} = $clientinfo[0]; # sysread / close won't work on fileno
$nhash{TYPE} = $type; $nhash{TYPE} = $type;