Esempio n. 1
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()));
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /**
  * process RegisterMessage
  *
  * @param \Thruway\Session $session
  * @param \Thruway\Message\RegisterMessage $msg
  */
 private function processRegister(Session $session, RegisterMessage $msg)
 {
     // check for valid URI
     if (!Utils::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;
         }
     }
 }
Esempio n. 4
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;
 }