Skip to content

Commit 6342673

Browse files
committed
Add default DNS resolver IP
1 parent 82f6178 commit 6342673

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
# PHP MQTT Client
22

3-
phpMqttClient is an MQTT client library for PHP. Its based on the reactPHP
4-
socket-client and added the mqtt protocol specific functions. I hope its a
5-
better starting point that the existing php mqtt libraries.
3+
phpMqttClient is an MQTT client library for PHP. Its based on the reactPHP socket-client and added the MQTT protocol
4+
specific functions. I hope its a better starting point that the existing PHP MQTT libraries.
65

76
[![Build Status](https://travis-ci.org/oliverlorenz/phpMqttClient.svg?branch=master)](https://travis-ci.org/oliverlorenz/phpMqttClient)
87
[![Code Climate](https://codeclimate.com/github/oliverlorenz/phpMqttClient/badges/gpa.svg)](https://codeclimate.com/github/oliverlorenz/phpMqttClient)
98
[![Test Coverage](https://codeclimate.com/github/oliverlorenz/phpMqttClient/badges/coverage.svg)](https://codeclimate.com/github/oliverlorenz/phpMqttClient/coverage)
109

1110
## Goal
1211

13-
Goal of this project is easy to use MQTT client for PHP in a modern architecture
14-
without using any php modules. Currently, only protocol version 4 (mqtt 3.1.1) is implemented.
12+
Goal of this project is easy to use MQTT client for PHP in a modern architecture without using any php modules.
13+
Currently, only protocol version 4 (mqtt 3.1.1) is implemented.
1514
* Protocol specifications: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html
1615

1716
## Example publish
1817

1918
```php
2019
$config = require 'config.php';
2120

22-
$connector = ClientFactory::createClient(new Version4(), '8.8.8.8');
21+
$connector = ClientFactory::createClient(new Version4());
2322

2423
$p = $connector->create($config['server'], $config['port'], $config['options']);
2524
$p->then(function(Stream $stream) use ($connector) {
@@ -33,7 +32,7 @@ $connector->getLoop()->run();
3332
```php
3433
$config = require 'config.php';
3534

36-
$connector = ClientFactory::createClient(new Version4(), '8.8.8.8');
35+
$connector = ClientFactory::createClient(new Version4());
3736

3837
$p = $connector->create($config['server'], $config['port'], $config['options']);
3938
$p->then(function(\React\Stream\Stream $stream) use ($connector) {

src/ClientFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
class ClientFactory
1010
{
11-
public static function createClient(Version $version, $resolverIp)
11+
public static function createClient(Version $version, $resolverIp = '8.8.8.8')
1212
{
1313
$loop = EventLoopFactory::create();
1414
$resolver = self::createDnsResolver($resolverIp, $loop);
1515

1616
return new Connector($loop, $resolver, $version);
1717
}
1818

19-
public static function createSecureClient(Version $version, $resolverIp)
19+
public static function createSecureClient(Version $version, $resolverIp = '8.8.8.8')
2020
{
2121
$loop = EventLoopFactory::create();
2222
$resolver = self::createDnsResolver($resolverIp, $loop);

0 commit comments

Comments
 (0)