Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function dispatch(ConnectionInterface $conn, $name, array $message, array $options, ConnectionContextInterface $context)
 {
     if (!array_key_exists($name, $this->handlers)) {
         throw new HandlerNotFoundException($name);
     }
     $error = false;
     try {
         $message = $this->handlers[$name]->handle($conn, $message, $context);
     } catch (MessageHandlerException $ex) {
         $message = $ex->getResponseMessage();
         $error = true;
     }
     return $this->messageBuilder->build($name, $message, $options, $error);
 }
 /**
  * Sends an update with the new collaborators to every collaborator.
  *
  * @param string $type The type of the entity
  * @param mixed $id The id of the entity
  * @param Collaboration[] $users The users currently working on the entity with the given identity
  */
 private function sendUpdate($type, $id, $users)
 {
     $identifier = $this->getUniqueCollaborationKey($type, $id);
     $message = $this->messageBuilder->build('sulu_collaboration', ['command' => 'update', 'type' => $type, 'id' => $id, 'users' => $users], []);
     $entityCollaborations = $this->collaborationsEntityCache->fetch($identifier) ?: [];
     foreach ($entityCollaborations as $collaboration) {
         /** @var $collaboration Collaboration */
         if (!array_key_exists($collaboration->getConnectionId(), $this->connections)) {
             // necessary because it has also to work with the ajax fallback, which does not store connections
             continue;
         }
         $this->connections[$collaboration->getConnectionId()]->send($message);
     }
 }