Thruway\Call::processCancel PHP Method

processCancel() public method

Return true if the Call should be removed from active calls
public processCancel ( Session $session, Thruway\Message\CancelMessage $msg ) : boolean
$session Session
$msg Thruway\Message\CancelMessage
return boolean
    public function processCancel(Session $session, CancelMessage $msg)
    {
        if ($this->getCallerSession() !== $session) {
            Logger::warning($this, "session " . $session->getSessionId() . " attempted to cancel call they did not own.");
            return false;
        }
        if ($this->getCalleeSession() === null) {
            // this call has not been sent to a callee yet (it is in a queue)
            // we can just kill it and say it was canceled
            $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg, "wamp.error.canceled");
            $details = $errorMsg->getDetails() ?: (object) [];
            $details->_thruway_removed_from_queue = true;
            $session->sendMessage($errorMsg);
            return true;
        }
        $details = (object) [];
        if ($this->getCalleeSession()->getHelloMessage() instanceof HelloMessage) {
            $details = $this->getCalleeSession()->getHelloMessage()->getDetails();
        }
        $calleeSupportsCancel = false;
        if (isset($details->roles->callee->features->call_canceling) && is_scalar($details->roles->callee->features->call_canceling)) {
            $calleeSupportsCancel = (bool) $details->roles->callee->features->call_canceling;
        }
        if (!$calleeSupportsCancel) {
            $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg);
            $errorMsg->setErrorURI('wamp.error.not_supported');
            $session->sendMessage($errorMsg);
            return false;
        }
        $this->setCancelMessage($msg);
        $this->canceling = true;
        $calleeSession = $this->getCalleeSession();
        $interruptMessage = new InterruptMessage($this->getInvocationRequestId(), (object) []);
        $calleeSession->sendMessage($interruptMessage);
        $this->setInterruptMessage($interruptMessage);
        if (isset($msg->getOptions()->mode) && is_scalar($msg->getOptions()->mode) && $msg->getOptions()->mode == "killnowait") {
            $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg, "wamp.error.canceled");
            $session->sendMessage($errorMsg);
            return true;
        }
        return false;
    }