Skip to content

Commit

Permalink
comments in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bluerhinos committed Sep 6, 2017
1 parent 55956bb commit d3dcdb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
14 changes: 6 additions & 8 deletions examples/publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

require("../phpMQTT.php");

$server = "mqtt.example.com"; // change if necessary
$port = 1883; // change if necessary
$username = ""; // set your username
$password = ""; // set your password
$client_id = "phpMQTT-publisher"; // make sure this is unique for connecting to sever - you could use uniqid()

$server = "m11.cloudmqtt.com"; // change if necessary
$port = 13251; // change if necessary
$username = ""; // set your username
$password = ""; // set your password

$mqtt = new phpMQTT($server, $port, "phpMQTT-publisher");
$mqtt = new phpMQTT($server, $port, $client_id);

if ($mqtt->connect(true, NULL, $username, $password)) {
$mqtt->publish("bluerhinos/phpMQTT/examples/publishtest", "Hello World! at " . date("r"), 0);
$mqtt->close();
} else {
echo "Time out!\n";
}

?>
14 changes: 6 additions & 8 deletions examples/subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
require("../phpMQTT.php");


$server = "m11.cloudmqtt.com"; // change if necessary
$port = 13251; // change if necessary
$username = ""; // set your username
$password = ""; // set your password
$server = "mqtt.example.com"; // change if necessary
$port = 1883; // change if necessary
$username = ""; // set your username
$password = ""; // set your password
$client_id = "phpMQTT-subscriber"; // make sure this is unique for connecting to sever - you could use uniqid()

$mqtt = new phpMQTT($server, $port, "phpMQTT-subscriber");
$mqtt = new phpMQTT($server, $port, $client_id);

if(!$mqtt->connect(true, NULL, $username, $password)) {
exit(1);
Expand All @@ -29,6 +30,3 @@ function procmsg($topic, $msg){
echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n";
}


?>
2 changes: 0 additions & 2 deletions phpMQTT.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,5 +421,3 @@ function printstr($string){
}
}
}

?>

2 comments on commit d3dcdb4

@q1633717196
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个要用什么框架才能运行啊

@q1633717196
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我直接打开publish运行出错了,能不能具体解释一下该怎么操作啊,新手 ,
谢谢

Please sign in to comment.