Example #1
0
 /**
  * handle received message
  *
  * @param \Thruway\AbstractSession $session
  * @param \Thruway\Message\Message $msg
  * @return void
  */
 public function onMessage(AbstractSession $session, Message $msg)
 {
     if ($msg instanceof PublishedMessage) {
         $this->processPublished($msg);
     } elseif ($msg instanceof ErrorMessage) {
         $this->processError($msg);
     } else {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg));
     }
 }
Example #2
0
 /**
  * @param AbstractSession $session
  * @param Message $msg
  * @return mixed|void
  */
 public function onMessage(AbstractSession $session, Message $msg)
 {
     $this->manager->debug("Broker onMessage for " . json_encode($session->getTransport()->getTransportDetails()) . ": " . json_encode($msg));
     if ($msg instanceof PublishMessage) {
         $this->processPublish($session, $msg);
     } elseif ($msg instanceof SubscribeMessage) {
         $this->processSubscribe($session, $msg);
     } elseif ($msg instanceof UnsubscribedMessage) {
         $this->processUnsubscribe($session, $msg);
     } else {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg));
     }
 }
Example #3
0
 /**
  * Handle received message
  *
  * @param \Thruway\AbstractSession $session
  * @param \Thruway\Message\Message $msg
  * @throws \Exception
  * @return mixed|void
  */
 public function onMessage(AbstractSession $session, Message $msg)
 {
     Logger::debug($this, "Broker onMessage for " . json_encode($session->getTransport()->getTransportDetails()) . ": " . json_encode($msg));
     if ($msg instanceof PublishMessage) {
         $this->processPublish($session, $msg);
     } elseif ($msg instanceof SubscribeMessage) {
         $this->processSubscribe($session, $msg);
     } elseif ($msg instanceof UnsubscribeMessage) {
         $this->processUnsubscribe($session, $msg);
     } else {
         throw new \Exception("Unhandled message type sent to broker: " . get_class($msg));
     }
 }
Example #4
0
 /**
  * Set authenticated state
  *
  * @param boolean $authenticated
  */
 public function setAuthenticated($authenticated)
 {
     // make sure the metaevent is only sent when changing from
     // not-authenticate to authenticated
     if ($authenticated && !$this->authenticated) {
         // metaevent
         $this->getRealm()->publishMeta('wamp.metaevent.session.on_join', [$this->getMetaInfo()]);
     }
     parent::setAuthenticated($authenticated);
 }
Example #5
0
 /**
  * Set authenticated state
  *
  * @param boolean $authenticated
  */
 public function setAuthenticated($authenticated)
 {
     // generally, there is no provisions in the WAMP specs to change from
     // authenticated to unauthenticated
     if ($this->authenticated && !$authenticated) {
         $this->getManager()->error("Session changed from authenticated to unauthenticated");
     }
     // make sure the metaevent is only sent when changing from
     // not-authenticate to authenticated
     if ($authenticated && !$this->authenticated) {
         // metaevent
         $this->getRealm()->publishMeta('wamp.metaevent.session.on_join', [$this->getMetaInfo()]);
     }
     parent::setAuthenticated($authenticated);
 }
Example #6
0
 /**
  * Set authenticated state
  *
  * @param boolean $authenticated
  */
 public function setAuthenticated($authenticated)
 {
     // make sure the metaevent is only sent when changing from
     // not-authenticate to authenticated
     if ($authenticated && !$this->authenticated) {
         // metaevent
         $metaInfo = $this->getMetaInfo();
         $this->getRealm()->publishMeta('wamp.metaevent.session.on_join', [$metaInfo]);
         Logger::info($this, "Session joined: " . json_encode($metaInfo));
     }
     parent::setAuthenticated($authenticated);
 }