$http_worker = new Worker("http://x.x.x.x:2345");
$tcp_worker = new Worker("tcp://x.x.x.x:2346");
$http_worker->onMessage = function($connection,$data)
{
$connection->send($data);
foreach($tcp_worker->connections as $con){
$con->send("hello");
}
};
Worker::runAll();
命令行提示tcp_worker未定义。这样的交互方式不行吗?
是要加global ?
两个worker是分离的,无法直接通讯。
可以用http://doc3.workerman.net/component/channel-examples.html来做进程间通讯,
也可以利http://doc3.workerman.net/worker-development/listen.html
好的,我看看手册。