/** * @param Session $session * @param UnregisterMessage $msg * @throws \Exception * @return Message */ private function processUnregister(Session $session, UnregisterMessage $msg) { //find the procedure by registration id $this->registrations->rewind(); while ($this->registrations->valid()) { $registration = $this->registrations->current(); if ($registration->getId() == $msg->getRegistrationId()) { $this->registrations->next(); // make sure the session is the correct session if ($registration->getSession() !== $session) { throw new \Exception("Tried to unregister a procedure that belongs to a different session."); } $this->manager->debug('Unegistered: ' . $registration->getProcedureName()); $this->registrations->detach($registration); return new UnregisteredMessage($msg->getRequestId()); } else { $this->registrations->next(); } } $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg); $this->manager->error('No registration: ' . $msg->getRegistrationId()); return $errorMsg->setErrorURI('wamp.error.no_such_registration'); }
/** * Create Unregisterd message from unregister message * * @param \Thruway\Message\UnregisterMessage $msg * @return \Thruway\Message\UnregisteredMessage */ public static function createFromUnregisterMessage(UnregisterMessage $msg) { return new UnregisteredMessage($msg->getRequestId()); }