示例#1
0
文件: DILog.php 项目: szyhf/DIServer
 private function _getWorkerID()
 {
     if ($this->_workerID === -1) {
         if (Container::IsRegistered(\swoole_server::class)) {
             $this->_workerID = Container::GetInstance(\swoole_server::class)->worker_id;
         }
     }
     return $this->_workerID;
 }
示例#2
0
文件: Base.php 项目: szyhf/DIServer
 protected function tryInitInfo($force = false)
 {
     if (!isset($this->remoteIP) || $force) {
         //因为跨进程投递时server会改变,为了确保成功,不使用构造函数注入的方式获取当前server
         /** @var \swoole_server $swoole */
         $swoole = Container::GetInstance(\swoole_server::class);
         $connectionInfo = $swoole->connection_info($this->GetFD(), $this->GetFromID());
         $this->remoteIP = $connectionInfo['remote_ip'];
         $this->remotePort = $connectionInfo['remote_port'];
         $this->serverPort = $connectionInfo['server_port'];
         $this->connectTime = $connectionInfo['connect_time'];
         $this->lastTime = $connectionInfo['last_time'];
     }
 }
示例#3
0
 public function OnManagerStart(\swoole_server $server)
 {
     //各个进程的$server对象不是同一个,要重置。
     Container::Unregister(\swoole_server::class);
     Container::RegisterClassByInstance(\swoole_server::class, $server);
     $this->managerServer = Container::GetInstance(IManagerServer::class);
     Event::Listen('OnManagerStart', [&$server]);
     $this->managerServer->OnManagerStart($server);
 }
示例#4
0
 /**
  * @return \swoole_server
  */
 protected function getCurrentSwoole()
 {
     return Container::GetInstance(\swoole_server::class);
 }