workman怎么接收已经连接的socket传送的数据?

xiangcomein

你好,问题如标题,代码是:

$worker->onMessage = function($connection, $data)
{
    //var_dump($_GET, $_POST);
    // send 时会自动调用$connection->protocol::encode(),打包数据后再发送
    //$connection->send("hello");
    //error_log($data."\r\n",3,'/tmp/socket2.log');
    //post_data($data);
    $post_data = array();
    $post_data = $data;
    error_log($data."\r\n",3,'/tmp/socket2.log');
    $url='http://wap.we2life.com/base/charging/heart';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_exec($ch);

    foreach($connection->worker->connections as $con)
    {
        $con->send($data);
    }

};
// 运行worker
Worker::runAll();
3800 2 0
2个回答

xiangcomein

onMessage 是不是不能接收到已经建立连接的socket传送的数据?

  • 暂无评论
walkor 打赏

  • 暂无评论
年代过于久远,无法发表回答
×
🔝