@Override
 public void unregister(Session session) {
   for (ResourceHolder resource : resources.values()) {
     SessionHolder sessionHolder = resource.sessions.get(session.id());
     if (sessionHolder != null) {
       resource.stateMachine.unregister(sessionHolder.session);
     }
   }
 }
 @Override
 public void close(Session session) {
   for (ResourceHolder resource : resources.values()) {
     SessionHolder sessionHolder = resource.sessions.remove(session.id());
     if (sessionHolder != null) {
       resource.stateMachine.close(sessionHolder.session);
       sessionHolder.commit.close();
     }
   }
 }
 @Override
 @SuppressWarnings("unchecked")
 public synchronized Listener onEvent(String event, Consumer listener) {
   Listeners listeners = eventListeners.get(event);
   if (listeners == null) {
     listeners = new Listeners();
     eventListeners.put(event, listeners);
     parent.onEvent(event, message -> handleEvent(event, (InstanceEvent) message));
   }
   return listeners.add(listener);
 }
 @Override
 public Session publish(String event, Object message) {
   return parent.publish(event, new InstanceEvent<>(resource, message));
 }
 @Override
 public Session publish(String event) {
   return parent.publish(event, new InstanceEvent<>(resource, null));
 }
 @Override
 public Listener<State> onStateChange(Consumer<State> callback) {
   return parent.onStateChange(callback);
 }
 @Override
 public State state() {
   return parent.state();
 }