001package com.box.sdk;
002
003/**
004 * The listener interface for receiving events from an {@link EventStream}.
005 */
006public interface EventListener {
007    /**
008     * Invoked when an event is received from the API.
009     * @param event the received event.
010     */
011    void onEvent(BoxEvent event);
012
013    /**
014     * Invoked when an updated stream position is received from the API.
015     * @param position of the stream.
016     */
017    void onNextPosition(long position);
018
019    /**
020     * Invoked when an error occurs while waiting for events to be received.
021     *
022     * <p>When an EventStream encounters an exception, it will invoke this method on each of its listeners until one
023     * of them returns true, indicating that the exception was handled.</p>
024     *
025     * @param  e the exception that was thrown while waiting for events.
026     * @return   true if the exception was handled; otherwise false.
027     */
028    boolean onException(Throwable e);
029}