Exemple #1
0
 /**
  * Registers an event listener.
  *
  * <p>The registered {@link Consumer} will be {@link Consumer#accept(Object) called} when an event
  * is received from the Raft cluster for the session. {@link Session} implementations must
  * guarantee that consumers are always called in the same thread for the session. Therefore, no
  * two events will be received concurrently by the session. Additionally, events are guaranteed to
  * be received in the order in which they were sent by the state machine.
  *
  * @param event The event to which to listen.
  * @param callback The session receive callback.
  * @param <T> The session event type.
  * @return The listener context.
  * @throws NullPointerException if {@code event} or {@code callback} is null
  */
 public <T> Listener<T> onEvent(String event, Consumer<T> callback) {
   return listener.onEvent(event, callback);
 }
Exemple #2
0
 /**
  * Registers a void event listener.
  *
  * <p>The registered {@link Runnable} will be {@link Runnable#run() called} when an event is
  * received from the Raft cluster for the session. {@link Session} implementations must guarantee
  * that consumers are always called in the same thread for the session. Therefore, no two events
  * will be received concurrently by the session. Additionally, events are guaranteed to be
  * received in the order in which they were sent by the state machine.
  *
  * @param event The event to which to listen.
  * @param callback The session receive callback.
  * @return The listener context.
  * @throws NullPointerException if {@code event} or {@code callback} is null
  */
 public Listener<Void> onEvent(String event, Runnable callback) {
   return listener.onEvent(event, callback);
 }