clue/ssdp-react

Async Simple Service Discovery Protocol (SSDP), built on top of ReactPHP.

dev-master 2020-12-05 11:14 UTC

This package is auto-updated.

Last update: 2021-06-05 12:18:24 UTC


README

CI status

Async Simple Service Discovery Protocol (SSDP), built on top of ReactPHP.

SSDP is part of Universal Plug and Play (UPnP) 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 (PDF) and uses HTTP over Multicast UDP (HTTPMU) as defined in the IETF draft. As an alternative, some devices use DNS-Based Service Discovery (DNS-SD) instead as defined in RFC 6763.

Table of Contents

Note: This project is in early alpha stage! Feel free to report any issues you encounter.

Quickstart example

Once installed, you can use the following code to search all available UPnP devices in your network:

$loop = React\EventLoop\Factory::create();
$client = new Client($loop);

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

$loop->run();

See also the examples.

Install

The recommended way to install this library is through composer. New to composer?

{
    "require": {
        "clue/ssdp-react": "dev-master"
    }
}

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.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

$ composer install

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

$ php vendor/bin/phpunit

License

MIT