2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 01:46:08 +00:00

01_FHEMWEB.pm/fhemweb.js: another solution to the Foum #30515 Problem.

git-svn-id: https://svn.fhem.de/fhem/trunk@7264 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-12-19 16:13:11 +00:00
parent ee79141852
commit 938e6f9e87
2 changed files with 14 additions and 6 deletions

View File

@ -585,12 +585,14 @@ FW_answerCall($)
# NTFY_ORDER is larger than the normal order (50-) # NTFY_ORDER is larger than the normal order (50-)
$me->{NTFY_ORDER} = $FW_cname; # else notifyfn won't be called $me->{NTFY_ORDER} = $FW_cname; # else notifyfn won't be called
%ntfyHash = (); %ntfyHash = ();
$me->{inform}{since} = time()-5
if(!defined($me->{inform}{since}) || $me->{inform}{since} !~ m/^\d+$/);
my $sinceTimestamp = FmtDateTime($me->{inform}{since});
TcpServer_WriteBlocking($me, TcpServer_WriteBlocking($me,
"HTTP/1.1 200 OK\r\n". "HTTP/1.1 200 OK\r\n".
$FW_headercors. $FW_headercors.
"Content-Type: application/octet-stream; charset=$FW_encoding\r\n\r\n"); "Content-Type: application/octet-stream; charset=$FW_encoding\r\n\r\n".
# FW_roomStatesForInform($me)); # Hope we dont need it FW_roomStatesForInform($me, $sinceTimestamp));
return -1; return -1;
} }
@ -725,7 +727,8 @@ FW_answerCall($)
my $onload = AttrVal($FW_wname, "longpoll", 1) ? my $onload = AttrVal($FW_wname, "longpoll", 1) ?
"onload=\"FW_delayedStart()\"" : ""; "onload=\"FW_delayedStart()\"" : "";
my $csrf= ($FW_CSRF ? "fwcsrf='$defs{$FW_wname}{CSRFTOKEN}'" : ""); my $csrf= ($FW_CSRF ? "fwcsrf='$defs{$FW_wname}{CSRFTOKEN}'" : "");
FW_pO "</head>\n<body name=\"$t\" $csrf $onload>"; FW_pO "</head>\n<body generated=\"".(time()-1)
."\" name=\"$t\" $csrf $onload>";
if($FW_activateInform) { if($FW_activateInform) {
$cmd = "style eventMonitor $FW_activateInform"; $cmd = "style eventMonitor $FW_activateInform";
@ -2198,9 +2201,9 @@ FW_makeEdit($$$)
sub sub
FW_roomStatesForInform($) FW_roomStatesForInform($$)
{ {
my ($me) = @_; my ($me, $sinceTimestamp ) = @_;
return "" if($me->{inform}{type} !~ m/status/); return "" if($me->{inform}{type} !~ m/status/);
my %extPage = (); my %extPage = ();
@ -2209,6 +2212,10 @@ FW_roomStatesForInform($)
next if(!defined($defs{$dn})); next if(!defined($defs{$dn}));
my $t = $defs{$dn}{TYPE}; my $t = $defs{$dn}{TYPE};
next if(!$t || $modules{$t}{FW_atPageEnd}); next if(!$t || $modules{$t}{FW_atPageEnd});
my $lastChanged = OldTimestamp( $dn );
next if(!defined($lastChanged) || $lastChanged lt $sinceTimestamp);
my ($allSet, $cmdlist, $txt) = FW_devState($dn, "", \%extPage); my ($allSet, $cmdlist, $txt) = FW_devState($dn, "", \%extPage);
if($defs{$dn} && $defs{$dn}{STATE} && $defs{$dn}{TYPE} ne "weblink") { if($defs{$dn} && $defs{$dn}{STATE} && $defs{$dn}{TYPE} ne "weblink") {
push @data, "$dn<<$defs{$dn}{STATE}<<$txt"; push @data, "$dn<<$defs{$dn}{STATE}<<$txt";

View File

@ -174,6 +174,7 @@ FW_longpoll()
var query = location.pathname+"?XHR=1"+ var query = location.pathname+"?XHR=1"+
"&inform=type=status;filter="+filter+ "&inform=type=status;filter="+filter+
";since="+document.body.getAttribute("generated")+
"&timestamp="+new Date().getTime(); "&timestamp="+new Date().getTime();
query = addcsrf(query); query = addcsrf(query);
FW_pollConn.open("GET", query, true); FW_pollConn.open("GET", query, true);