| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.pusher.client.Pusher
public class Pusher
This class is the main entry point for accessing Pusher.
By creating a new Pusher instance and calling Pusher.connect() a connection to Pusher is established.
Subscriptions for data are represented by Channel objects, or subclasses thereof. Subscriptions
 are created by calling #Pusher.subscribe(String), #Pusher.subscribePrivate(String), #Pusher.subscribePresence(String) or
 one of the overloads.
| Constructor Summary | |
|---|---|
Pusher(String apiKey)
Creates a new instance of Pusher.  | 
|
Pusher(String apiKey,
       PusherOptions pusherOptions)
Creates a new instance of Pusher.  | 
|
| Method Summary | |
|---|---|
 void | 
connect()
Connects to Pusher.  | 
 void | 
connect(ConnectionEventListener eventListener,
        ConnectionState... connectionStates)
Binds a ConnectionEventListener to the specified events and then connects to Pusher. | 
 void | 
disconnect()
Disconnect from Pusher.  | 
 Connection | 
getConnection()
Gets the underlying Connection object that is being used by this instance of Pusher. | 
 Channel | 
subscribe(String channelName)
Subscribes to a public Channel. | 
 Channel | 
subscribe(String channelName,
          ChannelEventListener listener,
          String... eventNames)
Binds a ChannelEventListener to the specified events and then subscribes to a public Channel. | 
 PresenceChannel | 
subscribePresence(String channelName)
Subscribes to a PresenceChannel which requires authentication. | 
 PresenceChannel | 
subscribePresence(String channelName,
                  PresenceChannelEventListener listener,
                  String... eventNames)
Subscribes to a PresenceChannel which requires authentication. | 
 PrivateChannel | 
subscribePrivate(String channelName)
Subscribes to a PrivateChannel which requires authentication. | 
 PrivateChannel | 
subscribePrivate(String channelName,
                 PrivateChannelEventListener listener,
                 String... eventNames)
Subscribes to a PrivateChannel which requires authentication. | 
 void | 
unsubscribe(String channelName)
Unsubscribes from a channel using via the name of the channel.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public Pusher(String apiKey)
Creates a new instance of Pusher.
 Note that if you use this constructor you will not be able to subscribe to private or presence channels because no Authorizer has been set. If you want to use private or presence channels:
 
Authorizer interface, or use the HttpAuthorizer provided.PusherOptions and set the authorizer on it by calling PusherOptions.setAuthorizer(Authorizer).Pusher(String, PusherOptions) constructor to create an instance of Pusher.
 The PrivateChannelExampleApp and PresenceChannelExampleApp example applications show how to do this.
 
apiKey - Your Pusher API key.
public Pusher(String apiKey,
              PusherOptions pusherOptions)
apiKey - Your Pusher API key.pusherOptions - Options for the Pusher client library to use.| Method Detail | 
|---|
public Connection getConnection()
Connection object that is being used by this instance of Pusher.
Connection object.public void connect()
ConnectionEventListeners that have already been registered using
 the Connection.bind(ConnectionState, ConnectionEventListener) method will receive connection events.
 
 Calls are ignored (a connection is not attempted) if the Pusher.getConnection().getState() is not com.pusher.client.connection.ConnectionState.DISCONNECTED.
public void connect(ConnectionEventListener eventListener,
                    ConnectionState... connectionStates)
ConnectionEventListener to the specified events and then connects to Pusher. This is equivalent to binding a ConnectionEventListener using the Connection.bind(ConnectionState, ConnectionEventListener) method before connecting.
 
 Calls are ignored (a connection is not attempted) if the Pusher.getConnection().getState() is not com.pusher.client.connection.ConnectionState.DISCONNECTED.
eventListener - A ConnectionEventListener that will receive connection events. This can be null if you are not interested in receiving connection events, in which case you should call connect() instead of this method.connectionStates - An optional list of ConnectionStates to bind your ConnectionEventListener to before connecting to Pusher. If you do not specify any ConnectionStates then your ConnectionEventListener will be bound to all connection events. This is equivalent to calling connect(ConnectionEventListener, ConnectionState...) with ConnectionState.ALL.
IllegalArgumentException - If the ConnectionEventListener is null and at least one connection state has been specified.public void disconnect()
Calls are ignored if the Pusher.getConnection().getState() is not com.pusher.client.connection.ConnectionState.CONNECTED.
public Channel subscribe(String channelName)
Channel.
channelName - The name of the Channel to subscribe to.
Channel object representing your subscription.
public Channel subscribe(String channelName,
                         ChannelEventListener listener,
                         String... eventNames)
ChannelEventListener to the specified events and then subscribes to a public Channel.
channelName - The name of the Channel to subscribe to.listener - A ChannelEventListener to receive events. This can be null if you don't want to bind a listener at subscription time, in which case you should call subscribe(String) instead of this method.eventNames - An optional list of event names to bind your ChannelEventListener to before subscribing.
Channel object representing your subscription.
IllegalArgumentException - If any of the following are true:
             subscribePrivate(String, PrivateChannelEventListener, String...) instead of this method.ChannelEventListener is null.public PrivateChannel subscribePrivate(String channelName)
PrivateChannel which requires authentication.
channelName - The name of the channel to subscribe to.
PrivateChannel representing the subscription.
IllegalStateException - if a Authorizer has not been set for the Pusher instance via Pusher(String, PusherOptions).
public PrivateChannel subscribePrivate(String channelName,
                                       PrivateChannelEventListener listener,
                                       String... eventNames)
PrivateChannel which requires authentication.
channelName - The name of the channel to subscribe to.listener - A listener to be informed of both Pusher channel protocol events and subscription data events.eventNames - An optional list of names of events to be bound to on the channel. The equivalent of calling com.pusher.client.channel.Channel.bind(String, SubscriptionListener) on or more times.
PrivateChannel representing the subscription.
IllegalStateException - if a Authorizer has not been set for the Pusher instance via Pusher(String, PusherOptions).public PresenceChannel subscribePresence(String channelName)
PresenceChannel which requires authentication.
channelName - The name of the channel to subscribe to.
PresenceChannel representing the subscription.
IllegalStateException - if a Authorizer has not been set for the Pusher instance via Pusher(String, PusherOptions).
public PresenceChannel subscribePresence(String channelName,
                                         PresenceChannelEventListener listener,
                                         String... eventNames)
PresenceChannel which requires authentication.
channelName - The name of the channel to subscribe to.listener - A listener to be informed of Pusher channel protocol, including presence-specific events, and subscription data events.eventNames - An optional list of names of events to be bound to on the channel. The equivalent of calling com.pusher.client.channel.Channel.bind(String, SubscriptionListener) on or more times.
PresenceChannel representing the subscription.
IllegalStateException - if a Authorizer has not been set for the Pusher instance via Pusher(String, PusherOptions).public void unsubscribe(String channelName)
channelName - the name of the channel to be unsubscribed from.
IllegalStateException - if Pusher.getConnection().getState() is not CONNECTED
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||