code: public Listener<Session.State> onStateChange(Consumer<Session.State> callback) {
      Listener<Session.State> listener = new Listener<Session.State>() {
        @Override
        public void accept(Session.State state) {
          callback.accept(state);
        }
        @Override
        public void close() {
          changeListeners.remove(this);
        }
      };
      changeListeners.add(listener);
      return listener;
    }
docs: Registers a state change listener on the session manager.
  
  @param callback The state change listener callback.
  @return The state change listener.