/** * 当进程启动时一些初始化工作 * @return void */ protected function onWorkerStart() { Timer::add(1, array($this, 'checkGatewayConnections')); $this->checkGatewayConnections(); \GatewayWorker\Lib\Gateway::setBusinessWorker($this); if ($this->_onWorkerStart) { call_user_func($this->_onWorkerStart, $this); } }
/** * 当进程启动时一些初始化工作 * @return void */ protected function onWorkerStart() { if (!class_exists('\\Protocols\\GatewayProtocol')) { class_alias('\\GatewayWorker\\Protocols\\GatewayProtocol', 'Protocols\\GatewayProtocol'); } Timer::add(1, array($this, 'checkGatewayConnections')); $this->checkGatewayConnections(); \GatewayWorker\Lib\Gateway::setBusinessWorker($this); if ($this->_onWorkerStart) { call_user_func($this->_onWorkerStart, $this); } }
/** * 当进程启动时一些初始化工作 * @return void */ protected function onWorkerStart() { if (!class_exists('\\Protocols\\GatewayProtocol')) { class_alias('\\GatewayWorker\\Protocols\\GatewayProtocol', 'Protocols\\GatewayProtocol'); } $this->connectToRegister(); \GatewayWorker\Lib\Gateway::setBusinessWorker($this); if ($this->_onWorkerStart) { call_user_func($this->_onWorkerStart, $this); } // 业务超时信号处理 pcntl_signal(SIGALRM, array($this, 'timeoutHandler'), false); if (is_callable($this->eventHandler . '::onConnect')) { $this->_eventOnConnect = $this->eventHandler . '::onConnect'; } if (is_callable($this->eventHandler . '::onMessage')) { $this->_eventOnMessage = $this->eventHandler . '::onMessage'; } else { echo "Waring: {$this->eventHandler}::onMessage is not callable\n"; } if (is_callable($this->eventHandler . '::onClose')) { $this->_eventOnClose = $this->eventHandler . '::onClose'; } }
/** * 当进程启动时一些初始化工作 * @return void */ protected function onWorkerStart() { if (!class_exists('\\Protocols\\GatewayProtocol')) { class_alias('\\GatewayWorker\\Protocols\\GatewayProtocol', 'Protocols\\GatewayProtocol'); } $this->connectToRegister(); \GatewayWorker\Lib\Gateway::setBusinessWorker($this); if ($this->_onWorkerStart) { call_user_func($this->_onWorkerStart, $this); } }
/** * 当进程启动时一些初始化工作 * @return void */ protected function onWorkerStart() { if (!class_exists('\\Protocols\\GatewayProtocol')) { class_alias('\\GatewayWorker\\Protocols\\GatewayProtocol', 'Protocols\\GatewayProtocol'); } $this->connectToRegister(); \GatewayWorker\Lib\Gateway::setBusinessWorker($this); if ($this->_onWorkerStart) { call_user_func($this->_onWorkerStart, $this); } if (function_exists('pcntl_signal')) { // 业务超时信号处理 pcntl_signal(SIGALRM, array($this, 'timeoutHandler'), false); } else { $this->processTimeout = 0; } // 设置回调 if (is_callable($this->eventHandler . '::onConnect')) { $this->_eventOnConnect = $this->eventHandler . '::onConnect'; } if (is_callable($this->eventHandler . '::onMessage')) { $this->_eventOnMessage = $this->eventHandler . '::onMessage'; } else { echo "Waring: {$this->eventHandler}::onMessage is not callable\n"; } if (is_callable($this->eventHandler . '::onClose')) { $this->_eventOnClose = $this->eventHandler . '::onClose'; } // 如果Register服务器不在本地服务器,则需要保持心跳 if (strpos($this->registerAddress, '127.0.0.1') !== 0) { Timer::add(self::PERSISTENCE_CONNECTION_PING_INTERVAL, array($this, 'pingRegister')); } }
/** * 当进程启动时一些初始化工作 * @return void */ protected function onWorkerStart() { if (!class_exists('\\Protocols\\GatewayProtocol')) { class_alias('\\GatewayWorker\\Protocols\\GatewayProtocol', 'Protocols\\GatewayProtocol'); } $this->connectToRegister(); \GatewayWorker\Lib\Gateway::setBusinessWorker($this); if ($this->_onWorkerStart) { call_user_func($this->_onWorkerStart, $this); } // 业务超时信号处理 pcntl_signal(SIGALRM, array($this, 'timeoutHandler'), false); }