Thruway\Call::getInvocationMessage PHP Метод

getInvocationMessage() публичный Метод

Get InvocationMessage
public getInvocationMessage ( ) : Thruway\Message\InvocationMessage
Результат 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;
    }

Usage Example

Пример #1
0
 /**
  * Process call
  *
  * @param Call $call
  * @throws \Exception
  */
 public function processCall(Call $call)
 {
     if ($call->getRegistration() !== null) {
         throw new \Exception("Registration already set when asked to process call");
     }
     $call->setRegistration($this);
     $this->calls[] = $call;
     $this->session->incPendingCallCount();
     $callCount = count($this->calls);
     if ($callCount == 1) {
         // we just became busy
         $this->busyStart = microtime(true);
     }
     if ($callCount > $this->maxSimultaneousCalls) {
         $this->maxSimultaneousCalls = $callCount;
     }
     $this->invocationCount++;
     $this->lastCallStartedAt = new \DateTime();
     $this->getSession()->sendMessage($call->getInvocationMessage());
 }