public function onClose()
    {
        if ($this->realm !== null) {
            // only send the leave metaevent if we actually made it into the realm
            if ($this->isAuthenticated()) {
                // metaevent
                $this->getRealm()->publishMeta('wamp.metaevent.session.on_leave', [$this->getMetaInfo()]);
            }
            $this->dispatcher->dispatch('LeaveRealm', new LeaveRealmEvent($this->realm, $this));

            $this->realm = null;
        }
    }