コード例 #1
0
 public function testStdClassOptions()
 {
     $options = new \stdClass();
     $options->disclose_caller = true;
     $msg = new RegisterMessage(12345, $options, 'com.test.register');
     $this->assertTrue(is_object($msg->getOptions()));
     $expectedJson = '[64,12345,{"disclose_caller":true},"com.test.register"]';
     $this->assertEquals($expectedJson, json_encode($msg));
 }
コード例 #2
0
ファイル: Dealer.php プロジェクト: pacho104/redbpim
 /**
  * process RegisterMessage
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\RegisterMessage $msg
  */
 private function processRegister(Session $session, RegisterMessage $msg)
 {
     // check for valid URI
     if (!static::uriIsValid($msg->getProcedureName())) {
         $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.invalid_uri'));
         return;
     }
     //Check to see if the procedure is already registered
     /** @var Procedure $procedure */
     if (isset($this->procedures[$msg->getProcedureName()])) {
         $procedure = $this->procedures[$msg->getProcedureName()];
     } else {
         $procedure = new Procedure($msg->getProcedureName());
         $this->procedures[$msg->getProcedureName()] = $procedure;
     }
     if ($procedure->processRegister($session, $msg)) {
         // registration succeeded
         // make sure we have the registration in the collection
         // of registrations for this session
         if (!$this->registrationsBySession->contains($session)) {
             $this->registrationsBySession->attach($session, []);
         }
         $registrationsForThisSession = $this->registrationsBySession[$session];
         if (!in_array($procedure, $registrationsForThisSession)) {
             array_push($registrationsForThisSession, $procedure);
             $this->registrationsBySession[$session] = $registrationsForThisSession;
         }
     }
 }
コード例 #3
0
ファイル: Procedure.php プロジェクト: haroldmodesto/Thruway
 /**
  * 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;
     }
 }
コード例 #4
0
ファイル: Dealer.php プロジェクト: duanejeffers/Thruway
 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()));
 }
コード例 #5
0
ファイル: Registration.php プロジェクト: voryx/thruway
 /**
  * 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;
 }
コード例 #6
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;
 }