Пример #1
0
 public function __construct()
 {
     $this->param = ChildProcess::current()->getWorkerParam();
     $this->dispatcher = $this->param['dispatcher'];
     $this->logic = new $this->param['dispatchLogic']($this->dispatcher);
     if (!$this->logic instanceof DispatchLogicInterface) {
         throw new \RuntimeException(sprintf('%s must instanceof EPS\\ServerDispatcher\\DispatcherInterface', $this->param['dispatchLogic']), 1);
     }
     $this->accept = $this->param['acceptMessage'];
     $this->receive = $this->param['receiveMessage'];
     //添加连接处理状态
     EventLoop::addUsTimer([$this, 'onAccept'], 100);
     EventLoop::addUsTimer([$this, 'onReceive'], 10);
 }