code: @SuppressWarnings("unchecked")
    public <T> Listener<T> onEvent(String event, Consumer listener) {
      Set<Consumer> listeners = eventListeners.computeIfAbsent(event, e -> new CopyOnWriteArraySet<>());
      listeners.add(listener);
      return new Listener<T>() {
        @Override
        public void accept(T event) {
          listener.accept(event);
        }
        @Override
        public void close() {
          listeners.remove(listener);
        }
      };
    }
docs: Registers a session event listener.