示例#1
0
 /**
  * Remove all references to Call to it can be GCed
  *
  * @param Call $call
  */
 public function removeCall(Call $call)
 {
     $newQueue = new \SplQueue();
     while (!$this->callQueue->isEmpty()) {
         $c = $this->callQueue->dequeue();
         if ($c === $call) {
             continue;
         }
         $newQueue->enqueue($c);
     }
     $this->callQueue = $newQueue;
     $registration = $call->getRegistration();
     if ($registration) {
         $registration->removeCall($call);
     }
 }
示例#2
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());
 }
示例#3
0
 /**
  * Process call
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\CallMessage $msg
  * @return boolean
  */
 private function processCall(Session $session, CallMessage $msg)
 {
     if (!Utils::uriIsValid($msg->getProcedureName())) {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.invalid_uri'));
         return;
     }
     if (!isset($this->procedures[$msg->getProcedureName()])) {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_procedure'));
         return;
     }
     /* @var $procedure \Thruway\Procedure */
     $procedure = $this->procedures[$msg->getProcedureName()];
     $call = new Call($session, $msg, $procedure);
     $this->callInvocationIndex[$call->getInvocationRequestId()] = $call;
     $this->callRequestIndex[$msg->getRequestId()] = $call;
     $keepIndex = $procedure->processCall($session, $call);
     if (!$keepIndex) {
         $this->removeCall($call);
     }
 }
示例#4
0
 /**
  * Process call
  *
  * @param \Thruway\Session $session
  * @param Call $call
  * @throws \Exception
  * @return bool | Call
  */
 public function processCall(Session $session, Call $call)
 {
     // find a registration to call
     if (count($this->registrations) == 0) {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($call->getCallMessage(), 'wamp.error.no_such_procedure'));
         return false;
     }
     // just send it to the first one if we don't allow multiple registrations
     if (!$this->getAllowMultipleRegistrations()) {
         $this->registrations[0]->processCall($call);
     } else {
         $this->callQueue->enqueue($call);
         $this->processQueue();
     }
     return true;
 }