moving some scripts, making unsubsribe, disconnect and ending clean
This commit is contained in:
25
moha.php
25
moha.php
@ -156,6 +156,8 @@ $client = new Mosquitto\Client();
|
||||
$client->onConnect('connectResponse');
|
||||
$client->onDisconnect('disconnectResponse');
|
||||
$client->onSubscribe('subscribeResponse');
|
||||
$client->onUnsubscribe('unsubscribeResponse');
|
||||
|
||||
$client->onMessage('message');
|
||||
$client->onLog('logger');
|
||||
$client->onPublish('publishResponse');
|
||||
@ -250,25 +252,30 @@ function loadHooks($dir, &$hookList)
|
||||
|
||||
function endMoha()
|
||||
{
|
||||
global $topics, $nSubscribed ,$client;
|
||||
global $topics, $nSubscribed ,$client, $logFh, $connected;
|
||||
$x = 0;
|
||||
foreach($topics as $topic => $object)
|
||||
/*foreach($topics as $topic => $object)
|
||||
{
|
||||
if ($object->status)
|
||||
{
|
||||
$mid = $client->unsubscribe($topic);
|
||||
$mids[$mid] = $topic;
|
||||
{*/
|
||||
$mid = $client->unsubscribe("#");
|
||||
/*$mids[$mid] = $topic;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
while ($nSubscribed != 0)
|
||||
while ($connected)
|
||||
{
|
||||
//echo $nSubscribed;0x00124b0022ebac5c
|
||||
if ( $x++ > 60) exit (0);
|
||||
if ( $x++ > 60)
|
||||
{
|
||||
$client->disconnect();
|
||||
fclose($logFh);
|
||||
exit (1);
|
||||
}
|
||||
$client->loop();
|
||||
}
|
||||
$client->disconnect();
|
||||
fclose($logFh);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user