mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 23:06:37 +00:00
98_fheminfo.pm: send blocking unless called with $cl
git-svn-id: https://svn.fhem.de/fhem/trunk@14764 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d4bef8bc4a
commit
b4f6a5ffac
@ -59,7 +59,7 @@ sub CommandFheminfo($$) {
|
||||
return toJSON(\%fhemInfo);
|
||||
}
|
||||
|
||||
_fi2_Send() if $doSend;
|
||||
_fi2_Send($cl) if $doSend;
|
||||
|
||||
# do not return statistics data if called from update
|
||||
return "Statistics data sent to server. See Logfile (level 4) for details." unless defined($cl);
|
||||
@ -145,7 +145,10 @@ sub _fi2_Count() {
|
||||
return;
|
||||
}
|
||||
|
||||
sub _fi2_Send() {
|
||||
sub _fi2_Send($) {
|
||||
my ($cl) = shift;
|
||||
$cl //= undef;
|
||||
|
||||
my $json = toJSON(\%fhemInfo);
|
||||
|
||||
Log3("fheminfo",4,"fheminfo: $json");
|
||||
@ -154,6 +157,7 @@ sub _fi2_Send() {
|
||||
$hu_hash{url} = $cmds{fheminfo}{uri};
|
||||
$hu_hash{data} = "uniqueID=".$fhemInfo{$c_system}{'uniqueID'}."&json=$json";
|
||||
$hu_hash{header} = "User-Agent: FHEM";
|
||||
if (defined($cl)) {
|
||||
$hu_hash{callback} = sub($$$) {
|
||||
my ($hash, $err, $data) = @_;
|
||||
if($err) {
|
||||
@ -163,6 +167,14 @@ sub _fi2_Send() {
|
||||
}
|
||||
};
|
||||
HttpUtils_NonblockingGet(\%hu_hash);
|
||||
} else {
|
||||
my ($err, $data) = HttpUtils_BlockingGet(\%hu_hash);
|
||||
if($err) {
|
||||
Log 1, "fheminfo send: Server ERROR: $err";
|
||||
} else {
|
||||
Log3("fheminfo",4,"fheminfo send: Server RESPONSE: $data");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user