Subscription part added

This commit is contained in:
Salman Zafar 2019-06-11 19:38:10 +05:00
parent d0a6435139
commit 6a8b433192
1 changed files with 35 additions and 2 deletions

View File

@ -83,6 +83,39 @@ public function SendMsgViaMqtt($topic, $message)
return false; return false;
} }
``` ```
### Tested on php 7.3 and laravel 5.7 and also laravel 5.8
## Subscription Part is in development #### Subscribing topic
```
use Salman\Mqtt\MqttClass\Mqtt;
public function SubscribetoTopic($topic)
{
Mqtt::ConnectAndSubscribe($topic, function($topic, $msg){
echo "Msg Received: \n";
echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n";
});
}
```
#### Subscribing topic using Facade
```
use Mqtt;
public function SubscribetoTopic($topic)
{
$mqtt = new Mqtt();
$mqtt->ConnectAndSubscribe($topic, function($topic, $msg){
echo "Msg Received: \n";
echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n";
});
}
```
### Tested on php 7.3 and laravel 5.7 and also laravel 5.8