getSession() public method

Get session
public getSession ( ) : Session
return Thruway\Session
Exemplo n.º 1
0
 /**
  * Gets and published the topics state to this subscription
  *
  * @param Subscription $subscription
  * @return mixed
  */
 public function publishState(Subscription $subscription)
 {
     //Pause all non-state building event messages
     $subscription->pauseForState();
     $sessionId = $subscription->getSession()->getSessionId();
     $this->clientSession->call($this->getProcedureName(), [$subscription->getUri(), $sessionId, $subscription->getOptions(), $subscription->getSession()->getAuthenticationDetails()])->then(function ($res) use($subscription) {
         $pubId = null;
         if (isset($res[0])) {
             $pubId = $res[0];
         }
         $subscription->unPauseForState($pubId);
     }, function ($error) use($subscription) {
         Logger::error($this, "Could not call '{$this->getProcedureName()}' when restoring state");
         $subscription->unPauseForState();
     });
 }
Exemplo n.º 2
0
 /**
  * Send an Event Message for each subscription
  * @param Session $session
  * @param PublishMessage $msg
  * @param Subscription $subscription
  */
 private function sendEventMessage(Session $session, PublishMessage $msg, Subscription $subscription)
 {
     $sessionId = $subscription->getSession()->getSessionId();
     $authroles = [];
     $authid = "";
     $authenticationDetails = $subscription->getSession()->getAuthenticationDetails();
     if ($authenticationDetails) {
         $authroles = $authenticationDetails->getAuthRoles();
         $authid = $authenticationDetails->getAuthId();
     }
     if ((!$msg->excludeMe() || $subscription->getSession() != $session) && !$msg->isExcluded($sessionId) && $msg->isWhiteListed($sessionId) && $msg->hasEligibleAuthrole($authroles) && $msg->hasEligibleAuthid($authid)) {
         $eventMsg = EventMessage::createFromPublishMessage($msg, $subscription->getId());
         if ($subscription->isDisclosePublisher() === true) {
             $eventMsg->disclosePublisher($session);
         }
         if ($this->getMatchType() != "exact") {
             $eventMsg->getDetails()->topic = $msg->getUri();
         }
         $subscription->sendEventMessage($eventMsg);
     }
 }