cleanOnline(); $redis = \Kiri::getDi()->get(Redis::class); if ($redis instanceof Redis) { $data = $redis->blPop(\config('redis.key'), 10); if (!empty($data)) { [$key, $data] = $data; $json = json_decode($data, true); $this->transport->send($json['userId'], json_encode($json['data'])); } } else { Coroutine::sleep(0.05); } $this->loop(); } /** * @return void */ public function cleanOnline(): void { $client = new Client(config('notice.host'), config('notice.port')); $client->post('/cleanOnline', []); $client->close(); } }