Subscription part implemented and updated readme

This commit is contained in:
Salman Zafar 2019-06-11 19:40:29 +05:00
parent 6a8b433192
commit 77a8b9db13
1 changed files with 3 additions and 3 deletions

View File

@ -91,7 +91,8 @@ use Salman\Mqtt\MqttClass\Mqtt;
public function SubscribetoTopic($topic) public function SubscribetoTopic($topic)
{ {
Mqtt::ConnectAndSubscribe($topic, function($topic, $msg){ $mqtt = new Mqtt();
$mqtt->ConnectAndSubscribe($topic, function($topic, $msg){
echo "Msg Received: \n"; echo "Msg Received: \n";
echo "Topic: {$topic}\n\n"; echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n"; echo "\t$msg\n\n";
@ -107,8 +108,7 @@ use Mqtt;
public function SubscribetoTopic($topic) public function SubscribetoTopic($topic)
{ {
$mqtt = new Mqtt(); Mqtt::ConnectAndSubscribe($topic, function($topic, $msg){
$mqtt->ConnectAndSubscribe($topic, function($topic, $msg){
echo "Msg Received: \n"; echo "Msg Received: \n";
echo "Topic: {$topic}\n\n"; echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n"; echo "\t$msg\n\n";