gatewayworker events.php设置命名空间导致启动失败

dishenghk

提示无法获取onmessage函数。。求解

4245 1 0
1个回答

walkor 打赏

events.php加命名空间时,需要设置eventHandler。

use \Workerman\Worker;
use \GatewayWorker\BusinessWorker;

$worker = new BusinessWorker();
$worker->name = 'ChatBusinessWorker';
$worker->count = 4;
$worker->registerAddress = '127.0.0.1:1236';

/*

  • 设置处理业务的类为MyEvent。
  • 如果类带有命名空间,则需要把命名空间加上
    */
    $worker->eventHandler = '\my\namespace\MyEvent';

if(!defined('GLOBAL_START'))
{
Worker::runAll();
}

http://doc2.workerman.net/326110
参考手册

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