Skip to content

Commit

Permalink
Test disconnect callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Oct 4, 2013
1 parent 4a6cac8 commit 6257e32
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/test.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php

$client = new Mosquitto\Client("test");
$client = new Mosquitto\Client();
$client->onConnect('callback');
$client->onDisconnect('disconnect');
$client->onSubscribe('subscribe');
$client->onMessage('message');
$client->connect("localhost", 1883, 5);
$client->subscribe('/#', 1);

while (true) {
for ($i = 0; $i < 10; $i++) {
$client->loop();
}
$client->disconnect();
unset($client);

function callback($r) {
echo "I got code {$r}\n";
Expand All @@ -22,3 +25,7 @@ function subscribe() {
function message($message) {
var_dump($message->topic, $message->payload);
}

function disconnect() {
echo "Disconnected cleanly\n";
}

0 comments on commit 6257e32

Please sign in to comment.