a lot of bugs corrected\nrdc_wc_eclairage
This commit is contained in:
@@ -13,23 +13,30 @@ function messageReceived($message)
|
||||
// payload is an array :
|
||||
// $key is property and $value is value of the property
|
||||
|
||||
function publish($topic, $payload, $commande="set") //, $eventKey)
|
||||
function publish($topic, $payloadArray, $commande="set") //, $eventKey)
|
||||
{
|
||||
global $client, $mids, $logFh, $testMode;
|
||||
$string = $topic . "/" . $commande;
|
||||
if ($testMode === false)
|
||||
{
|
||||
$mid = $client->publish($string, json_encode($payload) , 2);
|
||||
if (isset($mids[$mid]))
|
||||
if ($client !== null)
|
||||
{
|
||||
//echo "unsetting mids" .EOL;
|
||||
unset ($mids[$mid]);
|
||||
$mid = $client->publish($string, json_encode($payloadArray) , 2);
|
||||
if (isset($mids[$mid]))
|
||||
{
|
||||
//echo "unsetting mids" .EOL;
|
||||
unset ($mids[$mid]);
|
||||
}else
|
||||
{
|
||||
//echo "setting mids" .EOL;
|
||||
$mids[$mid] = true;
|
||||
}
|
||||
logger(LOG_INFO, $logFh, "Publishing " . $string . " with payload => " . json_encode($payloadArray), __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
{
|
||||
//echo "setting mids" .EOL;
|
||||
$mids[$mid] = true;
|
||||
logger(ERROR, $logFh, "MQTT client is null not publishing " . $string . " with payload => " . json_encode($payloadArray), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
logger(LOG_INFO, $logFh, "Publishing " . $string . " with payload => " . json_encode($payload), __FILE__ . ":" . __LINE__);
|
||||
|
||||
}else
|
||||
{
|
||||
logger(INFO, _("Test mode on: no publishing "), __FILE__ . ":" . __LINE__);
|
||||
|
Reference in New Issue
Block a user