Skip to content

Commit

Permalink
Use loopForever() in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Dec 21, 2017
1 parent 35d77cd commit ba7c5e0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@ The underlying library is based on callbacks and asynchronous operation. As such

$c = new Mosquitto\Client;
$c->onConnect(function() use ($c) {
$c->publish('mgdm/test', 'Hello', 2);
$c->publish('mgdm/test', 'Hello', 0);
$c->disconnect();
});

$c->connect('test.mosquitto.org');

for ($i = 0; $i < 100; $i++) {
// Loop around to permit the library to do its work
$c->loop(1);
}
$c->loopForever();

echo "Finished\n";
```
Expand Down

0 comments on commit ba7c5e0

Please sign in to comment.