监听2个端口,可以共用onWorkerStart和onMessage吗?

workerman_udp

$udp_worker = new Worker('udp://0.0.0.0:1112');
$udp_worker->count = 1;
$udp_worker->name = 'MyWebsocketWorker';

$udp_worker2 = new Worker('udp://0.0.0.0:1113');
$udp_worker2->count = 1;
$udp_worker2->name = 'MyWebsocketWorker2';

如何共用onWorkerStart和onMessage,感谢!

4325 2 0
2个回答

walkor 打赏

$udp_worker = new Worker('udp://0.0.0.0:1112');
$udp_worker->count = 1;
$udp_worker->name = 'MyWebsocketWorker';
$udp_worker->onMessage = 'on_message';

$udp_worker2 = new Worker('udp://0.0.0.0:1113');
$udp_worker2->count = 1;
$udp_worker2->name = 'MyWebsocketWorker2';
$udp_worker2->onMessage = 'on_message';

function on_message($con, $data) {
echo $data;
}

  • 暂无评论
workerman_udp

谢谢!

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