We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello, I need help
run(function () use ($baseChannels, $ws) { $channels = []; foreach ($baseChannels as $channel) { $channels[] = Yii::$app->notify->getHashKey().':'.$channel; } $redis = new \Swoole\Coroutine\Redis(); $redis->connect(Yii::$app->notify->param['ip'], Yii::$app->notify->param['port']); if ($redis->subscribe($channels)) // or use psubscribe { while ($msg = $redis->recv()) { list($type, $name, $result) = $msg; if ($type == 'subscribe') { print_r(['connections' => $this->ws->connections]); print_r(['sub' => $this->ws->getClientList(0)]); print_r(['connection_list' => $this->ws->connection_list() ]); } } });
I need to get a count connections.
In this case, there is a subscription record, but there are no connections
php --ri swoole
swoole v4.8.13
uname -a
php -v
gcc -v
php 7.4
The text was updated successfully, but these errors were encountered:
reference :
https://wiki.swoole.com/#/coroutine_client/init?id=%e5%8d%8f%e7%a8%8b%e5%ae%a2%e6%88%b7%e7%ab%af-lt-docsify-ignore-all-gt
https://wiki.swoole.com/#/coroutine_client/redis?id=%e5%8d%8f%e7%a8%8bredis%e5%ae%a2%e6%88%b7%e7%ab%af
https://wiki.swoole.com/#/runtime
example:
Co::set(['hook_flags' => SWOOLE_HOOK_TCP]); Co\run(function() { for ($c = 100; $c--;) { go(function () {//创建100个协程 $redis = new Redis(); $redis->connect('127.0.0.1', 6379);//此处产生协程调度,cpu切到下一个协程,不会阻塞进程 $redis->get('key');//此处产生协程调度,cpu切到下一个协程,不会阻塞进程 }); } });
Sorry, something went wrong.
Co::set(['hook_flags'=> SWOOLE_HOOK_ALL]); // v4.4+版本使用此方法。 // 或 Swoole\Runtime::enableCoroutine($flags = SWOOLE_HOOK_ALL);
No branches or pull requests
Hello, I need help
I need to get a count connections.
In this case, there is a subscription record, but there are no connections
php --ri swoole
)?swoole v4.8.13
uname -a
&php -v
&gcc -v
) ?php 7.4
The text was updated successfully, but these errors were encountered: