Пример #1
0
 public function testMakingCallIncrementsCallCount()
 {
     $mockSession = $this->getMockBuilder('\\Thruway\\Session')->setConstructorArgs([new \Thruway\Transport\DummyTransport()])->getMock();
     $this->assertEquals(0, $this->_registration->getCurrentCallCount());
     $callMsg = new \Thruway\Message\CallMessage(\Thruway\Session::getUniqueId(), new \stdClass(), 'test_procedure');
     $call = new \Thruway\Call($mockSession, $callMsg);
     $this->_registration->processCall($call);
     $this->assertEquals(1, $this->_registration->getCurrentCallCount());
 }
Пример #2
0
 public function testMakingCallIncrementsCallCount()
 {
     $mockSession = new \Thruway\Session(new \Thruway\Transport\DummyTransport());
     $this->assertEquals(0, $this->_registration->getCurrentCallCount());
     $callMsg = new \Thruway\Message\CallMessage(\Thruway\Common\Utils::getUniqueId(), new \stdClass(), 'test_procedure');
     $procedure = $this->getMockBuilder('\\Thruway\\Procedure')->disableOriginalConstructor()->getMock();
     $call = new \Thruway\Call($mockSession, $callMsg, $procedure);
     $this->_registration->processCall($call);
     $this->assertEquals(1, $this->_registration->getCurrentCallCount());
 }
Пример #3
0
 /**
  * @param CallMessage $msg
  * @param Registration $registration
  * @return static
  */
 static function createMessageFrom(CallMessage $msg, Registration $registration)
 {
     $requestId = Session::getUniqueId();
     $details = new \stdClass();
     return new static($requestId, $registration->getId(), $details, $msg->getArguments(), $msg->getArgumentsKw());
 }
Пример #4
0
 /**
  * Add registration
  *
  * @param \Thruway\Registration $registration
  * @return bool
  * @throws \Exception
  */
 private function addRegistration(Registration $registration, RegisterMessage $msg)
 {
     try {
         // make sure the uri is exactly the same
         if ($registration->getProcedureName() != $this->getProcedureName()) {
             throw new \Exception('Attempt to add registration to procedure with different procedure name.');
         }
         // make sure options match
         if ($registration->getAllowMultipleRegistrations() != $this->getAllowMultipleRegistrations()) {
             throw new \Exception('Registration and procedure must agree on allowing multiple registrations');
         }
         if ($registration->getDiscloseCaller() != $this->getDiscloseCaller()) {
             throw new \Exception('Registration and procedure must agree on disclose caller');
         }
         $this->registrations[] = $registration;
         $registration->getSession()->sendMessage(new RegisteredMessage($msg->getRequestId(), $registration->getId()));
         // now that we have added a new registration, process the queue if we are using it
         if ($this->getAllowMultipleRegistrations()) {
             $this->processQueue();
         }
         return true;
     } catch (\Exception $e) {
         $registration->getSession()->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg));
         return false;
     }
 }
Пример #5
0
 public function completeRegistration(Session $session, RegisterMessage $msg)
 {
     $registration = new Registration($session, $msg->getProcedureName());
     $options = (array) $msg->getOptions();
     if (isset($options['discloseCaller']) && $options['discloseCaller'] === true) {
         $registration->setDiscloseCaller(true);
     }
     $this->registrations->attach($registration);
     $this->manager->debug('Registered: ' . $registration->getProcedureName());
     $session->sendMessage(new RegisteredMessage($msg->getRequestId(), $registration->getId()));
 }
Пример #6
0
 /**
  * @param Registration $registration
  */
 public function setRegistration($registration)
 {
     $this->invocationMessage = null;
     if ($registration === null) {
         $this->setCalleeSession(null);
     } else {
         $this->setCalleeSession($registration->getSession());
     }
     $this->registration = $registration;
 }
Пример #7
0
 /**
  * Create Registration from RegisterMessage
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\RegisterMessage $msg
  * @return \Thruway\Registration
  */
 public static function createRegistrationFromRegisterMessage(Session $session, RegisterMessage $msg)
 {
     $registration = new Registration($session, $msg->getProcedureName());
     $options = $msg->getOptions();
     if (isset($options->disclose_caller) && $options->disclose_caller === true) {
         $registration->setDiscloseCaller(true);
     }
     if (isset($options->invoke)) {
         $registration->setInvokeType($options->invoke);
     } else {
         if (isset($options->thruway_multiregister) && $options->thruway_multiregister === true) {
             $registration->setInvokeType(Registration::THRUWAY_REGISTRATION);
         } else {
             $registration->setInvokeType(Registration::SINGLE_REGISTRATION);
         }
     }
     return $registration;
 }
Пример #8
0
 /**
  * Create Registration from RegisterMessage
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\RegisterMessage $msg
  * @return \Thruway\Registration
  */
 public static function createRegistrationFromRegisterMessage(Session $session, RegisterMessage $msg)
 {
     $registration = new Registration($session, $msg->getProcedureName());
     $options = $msg->getOptions();
     if (isset($options->disclose_caller) && $options->disclose_caller === true) {
         $registration->setDiscloseCaller(true);
     }
     if (isset($options->thruway_multiregister) && $options->thruway_multiregister === true) {
         $registration->setAllowMultipleRegistrations(true);
     }
     return $registration;
 }