webman自定义进程onMessage方法里面如何拿到work实例

xiewen_kevin

问题描述

Hi walkor,请问webman自定义进程里面如何拿到work实例呢?

class Websocket
{

public function onWorkerStart($worker)
{

}
public function onMessage(TcpConnection $connection, $data)
{
    //这里如何拿到work实例呢?
    echo "{$data}\n";

}

}

424 1 0
1个回答

walkor 打赏

这有难度么?😂

class Websocket
{
    protected $worker;

    public function onWorkerStart($worker)
    {
        $this->worker = $worker;
    }
    public function onMessage(TcpConnection $connection, $data)
    {
        $worker = $this->worker;
    }

}
×
🔝