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