We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ba7c5e0 commit 972ded9Copy full SHA for 972ded9
README.md
@@ -46,16 +46,25 @@ The underlying library is based on callbacks and asynchronous operation. As such
46
```php
47
<?php
48
49
-$c = new Mosquitto\Client;
50
-$c->onConnect(function() use ($c) {
51
- $c->publish('mgdm/test', 'Hello', 0);
52
- $c->disconnect();
+use Mosquitto\Client;
+
+$mid = 0;
+$c = new Mosquitto\Client("PHP");
53
+$c->onLog('var_dump');
54
+$c->onConnect(function() use ($c, &$mid) {
55
+ $mid = $c->publish("mgdm/test", "Hello", 2);
56
+});
57
58
+$c->onPublish(function($publishedId) use ($c, $mid) {
59
+ if ($publishedId == $mid) {
60
+ $c->disconnect();
61
+ }
62
});
63
-$c->connect('test.mosquitto.org');
64
+$c->connect("localhost");
65
$c->loopForever();
66
-echo "Finished\n";
67
+echo "Finished"
68
```
69
70
## Documentation
0 commit comments