コード例 #1
0
ファイル: Connection.php プロジェクト: voryx/ThruwayDrupal
 /**
  * @param ClientSession $session
  */
 public function onSessionStart(ClientSession $session)
 {
     try {
         //Temp place for keep-alive ping.  Every 30 seconds ping the far end and wait 5 seconds for a response
         $loop = $this->getClient()->getLoop();
         $loop->addPeriodicTimer(20, function () use($session, $loop) {
             $this->getClient()->getLogger()->info("Sending a Ping\n");
             $session->ping(5);
             $loop->tick();
         });
         $this->getClient()->getLogger()->info("Connection has opened");
         $this->session = $session;
         if ($this->resources && ($enabled = array_intersect_key($this->pluginManager->getDefinitions(), $this->resources))) {
             foreach ($enabled as $key => $resourceInfo) {
                 if ("thruway" === $resourceInfo['provider']) {
                     $resourceInfo['bundles'] = $this->resources[$key];
                     $this->handleResource($resourceInfo);
                 }
             }
         }
     } catch (\Exception $e) {
         //@todo handle exception
         print_r($e->getMessage());
     }
 }