-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b4cd70
commit ca12d74
Showing
1 changed file
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
# reactMqtt | ||
# ReactPHP MQTT | ||
|
||
reactMqtt is a mqtt client library PHP. Its based on the reactPHP socket-client and added the mqtt protocol specific functions | ||
reactMqtt is a mqtt client library PHP. Its based on the reactPHP socket-client and added the mqtt protocol specific functions. I hope its a better starting point that the existing php mqtt libraries. | ||
|
||
### Notice - (May 6th, 2015) | ||
This is the first initial commit. Only some things work already: | ||
* Connect | ||
* Connection Ack | ||
* publish | ||
|
||
I will add more features if I need them. If you need features: please give feedback or contribute to get this library running. | ||
|
||
## Goal | ||
|
||
Goal of this project is easy to use mqtt client for PHP in a modern architecture. Currently, only protocol version 4 (mqtt 3.1.1) is implemented. | ||
* Protocol specifications: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html | ||
|
||
## Example publish | ||
```php | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$loop = React\EventLoop\Factory::create(); | ||
|
||
$dnsResolverFactory = new React\Dns\Resolver\Factory(); | ||
$resolver = $dnsResolverFactory->createCached('8.8.8.8', $loop); | ||
|
||
$version = new oliverlorenz\reactphpmqtt\protocol\Version4(); | ||
$connector = new oliverlorenz\reactphpmqtt\Connector($loop, $resolver, $version); | ||
|
||
$connector->create('yourmqttserver.tdl', 1883); | ||
$connector->onConnected(function() use ($connector) { | ||
$connector->publish('a/b', 'example message'); | ||
}); | ||
$loop->run(); | ||
|
||
|
||
``` |