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();