Exemplo n.º 1
0
 /**
  * @param Session $session
  * @param CallMessage $msg
  * @return bool
  */
 private function processCall(Session $session, CallMessage $msg)
 {
     $registration = $this->getRegistrationByProcedureName($msg->getProcedureName());
     if (!$registration) {
         $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg);
         $this->manager->error('No registration for call message: ' . $msg->getProcedureName());
         $errorMsg->setErrorURI('wamp.error.no_such_registration');
         $session->sendMessage($errorMsg);
         return false;
     }
     $invocationMessage = InvocationMessage::createMessageFrom($msg, $registration);
     if ($registration->getDiscloseCaller() === true && $session->getAuthenticationDetails()) {
         $details = ["caller" => $session->getSessionId(), "authid" => $session->getAuthenticationDetails()->getAuthId(), "authmethod" => $session->getAuthenticationDetails()->getAuthMethod()];
         $invocationMessage->setDetails($details);
     }
     $call = new Call($msg, $session, $invocationMessage, $registration->getSession());
     $this->calls->attach($call);
     $registration->getSession()->sendMessage($invocationMessage);
 }
Exemplo n.º 2
0
 /**
  * Get InvocationMessage
  *
  * @throws \Exception
  * @return \Thruway\Message\InvocationMessage
  */
 public function getInvocationMessage()
 {
     if ($this->invocationMessage === null) {
         // try to create one
         if ($this->registration === null) {
             throw new \Exception("You must set the registration prior to calling getInvocationMessage");
         }
         if ($this->callMessage === null) {
             throw new \Exception("You must set the CallMessage prior to calling getInvocationMessage");
         }
         $invocationMessage = InvocationMessage::createMessageFrom($this->getCallMessage(), $this->getRegistration());
         $invocationMessage->setRequestId($this->getInvocationRequestId());
         $details = [];
         if ($this->getRegistration()->getDiscloseCaller() === true && $this->getCallerSession()->getAuthenticationDetails()) {
             $authenticationDetails = $this->getCallerSession()->getAuthenticationDetails();
             $details = ["caller" => $this->getCallerSession()->getSessionId(), "authid" => $authenticationDetails->getAuthId(), "authrole" => $authenticationDetails->getAuthRole(), "authroles" => $authenticationDetails->getAuthRoles(), "authmethod" => $authenticationDetails->getAuthMethod()];
             if ($authenticationDetails->getAuthExtra() !== null) {
                 $details["_thruway_authextra"] = $authenticationDetails->getAuthExtra();
             }
         }
         // TODO: check to see if callee supports progressive call
         $callOptions = $this->getCallMessage()->getOptions();
         $isProgressive = false;
         if (is_object($callOptions) && isset($callOptions->receive_progress) && $callOptions->receive_progress) {
             $details = array_merge($details, ["receive_progress" => true]);
             $isProgressive = true;
         }
         // if nothing was added to details - change ot stdClass so it will serialize correctly
         if (count($details) == 0) {
             $details = new \stdClass();
         }
         $invocationMessage->setDetails($details);
         $this->setIsProgressive($isProgressive);
         $this->setInvocationMessage($invocationMessage);
     }
     return $this->invocationMessage;
 }