Example #1
0
 /**
  * @param Session $session
  * @param PublishMessage $msg
  */
 public function processPublish(Session $session, PublishMessage $msg)
 {
     if ($this->getMatcher()->matches($msg->getTopicName(), $this->getUri(), $this->getOptions())) {
         $this->lastPublicationId = $msg->getPublicationId();
         foreach ($this->getSubscriptions() as $subscription) {
             $this->sendEventMessage($session, $msg, $subscription);
         }
     }
 }
Example #2
0
 /**
  * Process publish message
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\PublishMessage $msg
  */
 protected function processPublish(Session $session, PublishMessage $msg)
 {
     if ($msg->getPublicationId() === null) {
         $msg->setPublicationId(Utils::getUniqueId());
     }
     /** @var SubscriptionGroup $subscriptionGroup */
     foreach ($this->subscriptionGroups as $subscriptionGroup) {
         $subscriptionGroup->processPublish($session, $msg);
     }
     if ($msg->acknowledge()) {
         $session->sendMessage(new PublishedMessage($msg->getRequestId(), $msg->getPublicationId()));
     }
 }
Example #3
0
 /**
  * Create event message from publish message
  *
  * @param \Thruway\Message\PublishMessage $msg
  * @param int $subscriptionId
  * @return \Thruway\Message\EventMessage
  */
 public static function createFromPublishMessage(PublishMessage $msg, $subscriptionId)
 {
     return new static($subscriptionId, $msg->getPublicationId(), new \stdClass(), $msg->getArguments(), $msg->getArgumentsKw(), $msg->getTopicName());
 }