From f24c7a8ad4d47704acd7ac60eeb7248e1354c4f3 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Fri, 28 Jul 2023 10:49:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E6=8E=A8=E9=80=81=E6=95=B0=E6=8D=AE=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/ws_task_real.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 web/ws_task_real.php diff --git a/web/ws_task_real.php b/web/ws_task_real.php new file mode 100644 index 0000000..1d41eb9 --- /dev/null +++ b/web/ws_task_real.php @@ -0,0 +1,30 @@ +onWorkerStart = function($worker) use($config) { + # 数据库链接不能在主进程,方法外是主进程 + $dm = new Dm($config['connections']['dm']); + // 每2.5秒执行一次 + $time_interval = 3; + Timer::add($time_interval, function()use($worker,$dm){ + foreach($worker->connections as $connection) { + $passData = PassFlow::realTimeData($dm); + $returnData = ['data' => $passData]; + $connection->send(json_encode($returnData)); + } + }); +}; +Worker::runAll(); \ No newline at end of file