Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation and examples #17

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# clue/reactphp-ssdp

[![CI status](https://github.com/clue/reactphp-ssdp/workflows/CI/badge.svg)](https://github.com/clue/reactphp-ssdp/actions)
[![CI status](https://github.com/clue/reactphp-ssdp/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-ssdp/actions)
[![installs on Packagist](https://img.shields.io/packagist/dt/clue/ssdp-react?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/ssdp-react)

Async [Simple Service Discovery Protocol (SSDP)](http://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol), built on top of [ReactPHP](https://reactphp.org/).
Async [Simple Service Discovery Protocol (SSDP)](https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol), built on top of [ReactPHP](https://reactphp.org/).

SSDP is part of [Universal Plug and Play (UPnP)](http://de.wikipedia.org/wiki/Universal_Plug_and_Play)
SSDP is part of [Universal Plug and Play (UPnP)](https://de.wikipedia.org/wiki/Universal_Plug_and_Play)
and is commonly used to discover network services on home networks without
requiring any manual configuration, such as automatically discovering printers,
multimedia devices and network routers.

This library implements SSDP as defined in the
[UPnP device architecture definition](http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf) (PDF)
and uses HTTP over Multicast UDP (HTTPMU) as defined in the
[IETF draft](https://tools.ietf.org/html/draft-goland-http-udp-01).
[IETF draft](https://datatracker.ietf.org/doc/html/draft-goland-http-udp-01).
As an alternative, some devices use DNS-Based Service Discovery (DNS-SD) instead
as defined in [RFC 6763](http://tools.ietf.org/html/rfc6763).
as defined in [RFC 6763](https://tools.ietf.org/html/rfc6763).
yadaiio marked this conversation as resolved.
Show resolved Hide resolved

**Table of Contents**

Expand All @@ -31,13 +31,17 @@ as defined in [RFC 6763](http://tools.ietf.org/html/rfc6763).
Once [installed](#install), you can use the following code to search all available UPnP devices in your network:

```php
<?php

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

$client = new Clue\React\Ssdp\Client();

$client->search()->then(
function () {
echo 'Search completed' . PHP_EOL;
},
function($e) {
function(Exception $e) {
echo 'There was an error searching for devices: ' . $e . PHP_EOL;
},
function ($progress) {
Expand All @@ -48,11 +52,11 @@ $client->search()->then(
);
yadaiio marked this conversation as resolved.
Show resolved Hide resolved
```

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

## Install

The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)
The recommended way to install this library is [through composer](https://getcomposer.org/). [New to composer?](https://getcomposer.org/doc/00-intro.md)

```JSON
{
Expand All @@ -65,21 +69,21 @@ The recommended way to install this library is [through composer](http://getcomp
This project aims to run on any platform and thus does not require any PHP
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
HHVM.
It's *highly recommended to use PHP 7+* for this project.
It's *highly recommended to use the latest supported PHP version* for this project.

## Tests

To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org):
dependencies [through Composer](https://getcomposer.org/):

```bash
$ composer install
composer install
```

To run the test suite, go to the project root and run:

```bash
$ php vendor/bin/phpunit
vendor/bin/phpunit
```

## License
Expand Down
6 changes: 2 additions & 4 deletions examples/demo.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<?php

use Clue\React\Ssdp\Client;

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

$client = new Client();
$client = new Clue\React\Ssdp\Client();

$client->search()->then(
function () {
echo 'Search completed' . PHP_EOL;
},
function($e) {
function(Exception $e) {
echo 'There was an error searching for devices: ' . $e . PHP_EOL;
},
function ($progress) {
Expand Down