It holds detail information about the upgrade request of the websocket connection, the handler name and the user can put his own session variables into a parameter bag.
Inheritance: implements Sulu\Component\Websocket\ConnectionContext\ConnectionContextInterface
コード例 #1
0
 /**
  * Called when the user has left the page.
  *
  * @param MessageHandlerContext $context
  * @param array $msg
  *
  * @return array
  */
 private function leave(MessageHandlerContext $context, array $msg)
 {
     $this->removeCollaboration($msg['type'], $msg['id'], $context->getId());
     $users = $this->getUsersInformation($msg['type'], $msg['id']);
     $this->sendUpdate($msg['type'], $msg['id'], $users);
     return ['type' => $msg['type'], 'id' => $msg['id'], 'users' => $users];
 }
コード例 #2
0
 /**
  * Connection lost.
  *
  * @param ConnectionInterface $conn
  * @param MessageHandlerContext $context
  */
 public function onClose(ConnectionInterface $conn, MessageHandlerContext $context)
 {
     // get session vars
     $user = $context->get('user');
     $locale = $context->get('locale');
     $contentUuid = $context->get('content');
     $webspaceKey = $context->get('webspaceKey');
     $this->preview->stop($user, $contentUuid, $webspaceKey, $locale);
 }
コード例 #3
0
 /**
  * Updates properties of current session content.
  *
  * @param ConnectionInterface   $from
  * @param MessageHandlerContext $context
  * @param array                 $msg
  *
  * @return array
  *
  * @throws PreviewNotStartedException
  * @throws MissingParameterException
  */
 private function update(ConnectionInterface $from, MessageHandlerContext $context, $msg)
 {
     // check context parameters
     if (!$context->has('content') && !$context->has('locale') && !$context->has('webspaceKey') && !$context->has('user')) {
         throw new PreviewNotStartedException();
     }
     // get user id
     $user = $context->get('user');
     // get session vars
     $contentUuid = $context->get('content');
     $locale = $context->get('locale');
     $webspaceKey = $context->get('webspaceKey');
     // init msg vars
     if (!array_key_exists('data', $msg) && is_array($msg['data'])) {
         throw new MissingParameterException('data');
     }
     $changes = $msg['data'];
     $this->requestAnalyzer->setWebspaceKey($webspaceKey);
     $this->requestAnalyzer->setLocalizationCode($locale);
     foreach ($changes as $property => $data) {
         // update property
         $this->preview->updateProperty($user, $contentUuid, $webspaceKey, $locale, $property, $data);
     }
     return ['command' => 'update', 'content' => $contentUuid, 'data' => $this->preview->getChanges($user, $contentUuid, $webspaceKey, $locale)];
 }
コード例 #4
0
ファイル: PreviewMessageHandler.php プロジェクト: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public function onClose(ConnectionInterface $conn, MessageHandlerContext $context)
 {
     $this->preview->stop($context->get('previewToken'));
     $context->clear();
 }
コード例 #5
0
 public function __construct(AuthenticatedConnectionContextInterface $context, $handlerName)
 {
     parent::__construct($context, $handlerName);
 }