protected function initMonitor()
 {
     Application::RegisterClass(\DIServer\Monitor\SwooleTable::class);
     Application::RegisterInterfaceByClass(\DIServer\Interfaces\IMonitor::class, \DIServer\Monitor\SwooleTable::class);
     $monitor = Application::GetInstance(\DIServer\Interfaces\IMonitor::class);
     $monitor->Bind();
 }
 protected function loadService($servicesConfig = [])
 {
     foreach ($servicesConfig as $iface => $imp) {
         Application::RegisterClass($imp);
         if (Application::IsAbstract($iface)) {
             Application::RegisterInterfaceByClass($iface, $imp);
         }
     }
 }
Example #3
0
 public function Bootstrap()
 {
     /** @var IListener $defaultListener */
     $defaultListener = $this->initListener()->current();
     //拿出第一个监听作为构造函数的参数
     $initParams = ['serv_host' => $defaultListener->GetHost(), 'serv_port' => $defaultListener->GetPort(), 'serv_mode' => SWOOLE_PROCESS, 'sock_type' => $defaultListener->GetType()];
     Application::RegisterClass(\swoole_server::class, $initParams);
     $this->swoole = Application::GetInstance(\swoole_server::class);
     //记录一下
     $this->_listenerConfigs[get_class($defaultListener)] = ['Host' => $defaultListener->GetHost(), 'Port' => $defaultListener->GetPort(), 'Type' => $this->_getTypeName($defaultListener->GetType())];
     //注册剩余的Listener
     $this->initListener()->send('');
     $this->initProxy();
     //构造时已经自动完成了回调注册
     Log::Notice(['Listeners' => $this->_listenerConfigs]);
 }
Example #4
0
 private function _tryRegitryHandler($handlerID, $handlerClassName)
 {
     if (class_exists($handlerClassName)) {
         $handlerRefClass = new \ReflectionClass($handlerClassName);
         if ($handlerRefClass->isSubclassOf(IHandler::class)) {
             Application::RegisterClass($handlerClassName);
             Application::RegisterInterfaceByClass(IHandler::class, $handlerRefClass->getName(), $handlerRefClass->getName());
             $handlerObj = Application::GetInstance(IHandler::class, $handlerRefClass->getName());
             $this->handlers[$handlerID][] = $handlerObj;
         } else {
             Log::Warning("Load {$handlerClassName} is not instance of IHandler.");
         }
     } else {
         Log::Warning("Try to load {$handlerClassName} but not exist.");
     }
 }