Skip to content

Commit

Permalink
The QoS=2 example didn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Nov 21, 2018
1 parent ba7c5e0 commit 972ded9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,25 @@ The underlying library is based on callbacks and asynchronous operation. As such
```php
<?php

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

$mid = 0;
$c = new Mosquitto\Client("PHP");
$c->onLog('var_dump');
$c->onConnect(function() use ($c, &$mid) {
$mid = $c->publish("mgdm/test", "Hello", 2);
});

$c->onPublish(function($publishedId) use ($c, $mid) {
if ($publishedId == $mid) {
$c->disconnect();
}
});

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

echo "Finished\n";
echo "Finished"
```

## Documentation
Expand Down

0 comments on commit 972ded9

Please sign in to comment.