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