Esempio n. 1
0
 private function receiveAddWebHook(User $user, ConnectionInterface $from, $msg, $type, $comKey)
 {
     $endpoint = $msg['endpoint'];
     if ($webHook = $this->getWebHook($user, $from, $type, $comKey, $endpoint)) {
         $this->webHooks->add($webHook);
         $this->logger->info("WebHook added", ['endpoint' => $webHook->getEndpoint(), 'conn' => $from->resourceId, 'ck' => $comKey]);
         $socketClients = $this->getAttachedSocketClients($webHook);
         if (!count($socketClients)) {
             $this->logger->info("No client attached.", ['conn' => $from->resourceId, 'ck' => $comKey]);
         }
         foreach ($this->getAttachedSocketClients($webHook) as $socketClient) {
             $this->logger->info("Inform client for the new WebHook", ['client' => $socketClient->resourceId, 'endpoint' => $endpoint, 'conn' => $from->resourceId, 'ck' => $comKey]);
             $this->answer($socketClient, 'forwardAddWebHook', rand(100000, 999999), ['endpoint' => $webHook->getEndpoint()]);
         }
         $this->answerOk($from, $type, $comKey);
     } else {
         $this->answerError($from, $type, $comKey, '[REMOVE] WebHook was not found');
     }
 }
Esempio n. 2
0
 /**
  * @param WebHook $webHook
  */
 public function addWebHook(WebHook $webHook)
 {
     $this->webHooks->add($webHook);
     $webHook->setUser($this);
 }