001package com.pusher.client.connection;
002
003/**
004 * Represents a connection to Pusher.
005 */
006public interface Connection {
007    /**
008     * No need to call this via the API. Instead use {@link com.pusher.client.Pusher#connect}.
009     */
010    void connect();
011
012    /**
013     * Bind to connection events.
014     *
015     * @param state         The states to bind to.
016     * @param eventListener A listener to be called when the state changes.
017     */
018    void bind(ConnectionState state, ConnectionEventListener eventListener);
019
020    /**
021     * Unbind from connection state changes.
022     *
023     * @param state         The state to unbind from.
024     * @param eventListener The listener to be unbound.
025     * @return <code>true</code> if the unbind was successful, otherwise
026     * <code>false</code>.
027     */
028    boolean unbind(ConnectionState state, ConnectionEventListener eventListener);
029
030    /**
031     * Gets the current connection state.
032     *
033     * @return The state.
034     */
035    ConnectionState getState();
036
037    /**
038     * Gets a unique connection ID.
039     *
040     * @return The id.
041     */
042    String getSocketId();
043}