/**
* 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;
}
}