PHP code example of valeriitropin / socketio-redis-adapter
1. Go to this page and download the library: Download valeriitropin/socketio-redis-adapter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
valeriitropin / socketio-redis-adapter example snippets
use React\EventLoop\Factory as ReactFactory;
use ValeriiTropin\Socketio\RedisAdapter;
use Clue\React\Block;
use React\Promise;
$loop = ReactFactory::create();
$client = new RedisAdapter($loop);
$promise = $client->allRooms()->then(function ($rooms) use ($client) {
$promises = [];
foreach ($rooms as $room) {
$promises[] = $client->clients([$room])->then(function ($clients) use ($room) {
foreach ($clients as $client) {
echo $room . ' ' . $client . "\n";
}
});
}
return Promise\all($promises);
})->otherwise(function ($error) {
echo ($error->getMessage()) . "\n";
});
Block\await($promise, $loop);