Is it possible to do subscribing to mutliple topics on 1 command?
ioiofadhil opened this issue · comments
Giofadhil commented
Hi, Thanks for the package! I was wondering, can we do multiple subscribe in 1 cli artisan command?
My Command :
php artisan mqtt-subscribe
Code handler :
foreach (Device::all() as $device) {
$mqtt->subscribe($device->subscribe_topic, function( ... ) { ... }, 1);
$mqtt->loop(true);
}
I'm planning to run this command on supervisor with autorestart on. Is this good approach? Thanks!
Giofadhil commented
Sorry to bother! Incase anyone looking for this, i was wrongly wrote my loop inside the loop. It should be outside.
foreach ( ... ) {
...
}
$mqtt->loop(true);