Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions examples/subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require("../phpMQTT.php");


$server = "mqtt.example.com"; // change if necessary
$server = "127.0.0.1"; // change if necessary
$port = 1883; // change if necessary
$username = ""; // set your username
$password = ""; // set your password
Expand All @@ -15,7 +15,8 @@
exit(1);
}

$topics['bluerhinos/phpMQTT/examples/publishtest'] = array("qos" => 0, "function" => "procmsg");
echo "Connected to mqtt server...\n";
$topics['#'] = array("qos" => 0, "function" => "procmsg");
$mqtt->subscribe($topics, 0);

while($mqtt->proc()){
Expand All @@ -26,7 +27,5 @@
$mqtt->close();

function procmsg($topic, $msg){
echo "Msg Recieved: " . date("r") . "\n";
echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n";
echo "$topic = $msg\n";
}
Loading