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

0

$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,感谢!

已邀请:

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 - 酷毙~

赞同来自:

谢谢!

要回复问题请先登录注册