Exemple #1
0
 /**
  * Process Yield message
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\YieldMessage $msg
  * @return bool if we need to keep the call indexed
  */
 public function processYield(Session $session, YieldMessage $msg)
 {
     $keepIndex = true;
     $details = new \stdClass();
     $yieldOptions = $msg->getOptions();
     if (is_array($yieldOptions) && isset($yieldOptions['progress']) && $yieldOptions['progress']) {
         if ($this->isProgressive()) {
             $details = ["progress" => true];
         } else {
             // not sure what to do here - just going to drop progress
             // if we are getting progress messages that the caller didn't ask for
             return $keepIndex;
         }
     } else {
         $this->getRegistration()->removeCall($this);
         $keepIndex = false;
     }
     $resultMessage = new ResultMessage($this->getCallMessage()->getRequestId(), $details, $msg->getArguments(), $msg->getArgumentsKw());
     $this->getCallerSession()->sendMessage($resultMessage);
     return $keepIndex;
 }
Exemple #2
0
 /**
  * @param Session $session
  * @param YieldMessage $msg
  * @return bool
  */
 private function processYield(Session $session, YieldMessage $msg)
 {
     $call = $this->getCallByRequestId($msg->getRequestId());
     if (!$call) {
         $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg);
         $this->manager->error('No call for yield message: ' . $msg->getRequestId());
         $errorMsg->setErrorURI('wamp.error.no_such_procedure');
         $session->sendMessage($errorMsg);
         return false;
     }
     $details = new \stdClass();
     $this->calls->detach($call);
     $resultMessage = new ResultMessage($call->getCallMessage()->getRequestId(), $details, $msg->getArguments(), $msg->getArgumentsKw());
     $call->getCallerSession()->sendMessage($resultMessage);
 }
Exemple #3
0
 /**
  * process YieldMessage
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\YieldMessage $msg
  */
 private function processYield(Session $session, YieldMessage $msg)
 {
     /* @var $call Call */
     $call = isset($this->callInvocationIndex[$msg->getRequestId()]) ? $this->callInvocationIndex[$msg->getRequestId()] : null;
     if (!$call) {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg));
         Logger::error($this, "Was expecting a call");
         return;
     }
     $keepIndex = $call->processYield($session, $msg);
     if (!$keepIndex) {
         $this->removeCall($call);
     }
     /* @var $procedure \Thruway\Procedure */
     $procedure = isset($this->procedures[$call->getCallMessage()->getUri()]) ? $this->procedures[$call->getCallMessage()->getUri()] : null;
     if ($procedure && $procedure->getAllowMultipleRegistrations()) {
         $procedure->processQueue();
     }
     //Process queues on other registrations if we can take more requests
     if ($session->getPendingCallCount() == 0 && $this->registrationsBySession->contains($session)) {
         $this->processQueue($session);
     }
 }
Exemple #4
0
 /**
  * process YieldMessage
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\YieldMessage $msg
  */
 private function processYield(Session $session, YieldMessage $msg)
 {
     /* @var $call Call */
     $call = isset($this->callIndex[$msg->getRequestId()]) ? $this->callIndex[$msg->getRequestId()] : null;
     if ($call) {
         $keepIndex = $call->processYield($session, $msg);
         if (!$keepIndex) {
             unset($this->callIndex[$msg->getRequestId()]);
         }
         /* @var $procedure \Thruway\Procedure */
         $procedure = isset($this->procedures[$call->getCallMessage()->getUri()]) ? $this->procedures[$call->getCallMessage()->getUri()] : null;
         if ($procedure && $procedure->getAllowMultipleRegistrations()) {
             $procedure->processQueue();
         }
         //Process queues on other registrations if we can take more requests
         if ($session->getPendingCallCount() == 0 && $this->registrationsBySession->contains($session)) {
             $registrationsForThisSession = $this->registrationsBySession[$session];
             /** @var Registration $registration */
             foreach ($registrationsForThisSession as $registration) {
                 if ($registration->getAllowMultipleRegistrations()) {
                     // find the procedure for this registration
                     $procedure = $this->procedures[$registration->getProcedureName()];
                     $procedure->processQueue();
                 }
             }
         }
     }
     // TODO: This is an error - can I return a yield error?
 }