subscribe($topic); //时间 $timeSincePing = time(); while (true){ $function($cline,$topic); //心跳 if ($timeSincePing <= (time() - $cline->getKeepAlive())){ if ($cline->ping()) { $timeSincePing = time(); } } Coroutine::sleep(0.01); } } }