Skip to content

Releases: php-api-clients/pusher

1.0.0

02 Aug 05:58
1.0.0
Compare
Choose a tag to compare

Initial release

This initial release is stable but doesn't include all Pusher features yet. For now it can subscribe to channels in a given application and listen for incoming messages. The more advanced features will be added in v1.1 and v1.2.

Usage

$loop = Factory::create();
$client = AsyncClient::create($loop, 'Application ID here');

$client->channel('channel_name')->subscribe(
    function (Event $event) { // Gets called for each incoming event
        echo 'Channel: ', $event->getChannel(), PHP_EOL;
        echo 'Event: ', $event->getEvent(), PHP_EOL;
        echo 'Data: ', json_encode($event->getData()), PHP_EOL;
    },
    function ($e) { // Gets called on errors
        echo (string)$e;
    },
    function () { // Gets called when the end of the stream is reached
        echo 'Done!', PHP_EOL;
    }
);

$loop->run();