<?phpuse Workerman\Worker;use Workerman\Lib\Timer; require_once ‘../../web/Workerman/Autoloader.php‘;require_once ‘../../web/Channel/src/Client.php‘;require_once ‘../../web/Channel/src/Client.php‘ $worker = new Worker(‘text://0.0.0.0:8989‘);$worker->count = 1;$worker->reloadable = false; //平滑重启$worker->onConnect = function ($con)use($worker){ foreach($worker->connections as $connection){ $connection->send($con->id.‘上线了‘); }};//群发通知 这里只支持单进程的 $worker->count = 1; 如需支持多进程 可使用getway框架 或者引用Channel组件Worker::runAll();
时间: 2024-10-05 04:19:15