Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yadaiio committed Feb 26, 2024
1 parent 63fad80 commit 011c69f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ as defined in [RFC 6763](https://tools.ietf.org/html/rfc6763).
Once [installed](#install), you can use the following code to look up the address of a local domain name:

```php
$factory = new Factory();
<?php

require __DIR__ . '/vendor/autoload.php';

$factory = new Clue\React\Mdns\Factory();
$resolver = $factory->createResolver();

$resolver->lookup('hostname.local')->then(function ($ip) {
echo 'Found: ' . $ip . PHP_EOL;
$resolver->resolve('hostname.local')->then(function ($ip) {
echo 'Found: ' . $ip . PHP_EOL;
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
```

See also the [examples](examples).
See also the [examples](examples/).

## Usage

Expand Down Expand Up @@ -105,9 +111,13 @@ you should look into also using [clue/reactphp-block](https://github.com/clue/re
The resulting blocking code could look something like this:

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Clue\React\Block;

$factory = new Factory();
$factory = new Clue\React\Mdns\Factory();
$resolver = $factory->createResolver();

$promise = $resolver->lookup('me.local');
Expand Down
8 changes: 4 additions & 4 deletions examples/lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
$factory = new Clue\React\Mdns\Factory();
$mdns = $factory->createResolver();

$mdns->resolve($name)->then('e', 'e');

function e($v) {
$mdns->resolve($name)->then(function ($v) {
echo $v . PHP_EOL;
}
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

0 comments on commit 011c69f

Please sign in to comment.