com.pusher.client.example
Class PresenceChannelExampleApp

java.lang.Object
  extended by com.pusher.client.example.PresenceChannelExampleApp
All Implemented Interfaces:
ChannelEventListener, PresenceChannelEventListener, PrivateChannelEventListener, SubscriptionEventListener, ConnectionEventListener

public class PresenceChannelExampleApp
extends Object
implements ConnectionEventListener, PresenceChannelEventListener


Constructor Summary
PresenceChannelExampleApp(String[] args)
           
 
Method Summary
static void main(String[] args)
           
 void onAuthenticationFailure(String message, Exception e)
          Called when an attempt to authenticate a private channel fails.
 void onConnectionStateChange(ConnectionStateChange change)
          Callback that is fired whenever the ConnectionState of the Connection changes.
 void onError(String message, String code, Exception e)
          Callback that indicates either: An error message has been received from Pusher, or An error has occurred in the client library.
 void onEvent(String channelName, String eventName, String data)
          Callback that is fired whenever an event that this SubscriptionEventListener has been bound to is received.
 void onSubscriptionSucceeded(String channelName)
          Callback that is fired when a subscription success acknowledgement message is received from Pusher after subscribing to the channel.
 void onUsersInformationReceived(String channelName, Set<User> users)
          Called when the subscription has succeeded and an initial list of subscribed users has been received from Pusher.
 void userSubscribed(String channelName, User user)
          Called when a new user subscribes to the channel.
 void userUnsubscribed(String channelName, User user)
          Called when an existing user unsubscribes from the channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PresenceChannelExampleApp

public PresenceChannelExampleApp(String[] args)
Method Detail

main

public static void main(String[] args)

onConnectionStateChange

public void onConnectionStateChange(ConnectionStateChange change)
Description copied from interface: ConnectionEventListener

Callback that is fired whenever the ConnectionState of the Connection changes. The state typically changes during connection to Pusher and during disconnection and reconnection.

This callback is only fired if the ConnectionEventListener has been bound to the new state by calling Connection.bind(ConnectionState, ConnectionEventListener) with either the new state or ConnectionState.ALL.

Specified by:
onConnectionStateChange in interface ConnectionEventListener
Parameters:
change - An object that contains the previous state of the connection and the new state. The new state can be retrieved by calling ConnectionStateChange.getCurrentState().

onError

public void onError(String message,
                    String code,
                    Exception e)
Description copied from interface: ConnectionEventListener

Callback that indicates either:

All ConnectionEventListeners that have been registered by calling Connection.bind(ConnectionState, ConnectionEventListener) will receive this callback, even if the ConnectionEventListener is only bound to specific connection status changes.

Specified by:
onError in interface ConnectionEventListener
Parameters:
message - A message indicating the cause of the error.
code - The error code for the message. Can be null.
e - The exception that was thrown, if any. Can be null.

onUsersInformationReceived

public void onUsersInformationReceived(String channelName,
                                       Set<User> users)
Description copied from interface: PresenceChannelEventListener
Called when the subscription has succeeded and an initial list of subscribed users has been received from Pusher.

Specified by:
onUsersInformationReceived in interface PresenceChannelEventListener
Parameters:
channelName - The name of the channel the list is for.
users - The users.

userSubscribed

public void userSubscribed(String channelName,
                           User user)
Description copied from interface: PresenceChannelEventListener
Called when a new user subscribes to the channel.

Specified by:
userSubscribed in interface PresenceChannelEventListener
Parameters:
channelName - channelName The name of the channel the list is for.
user - The newly subscribed user.

userUnsubscribed

public void userUnsubscribed(String channelName,
                             User user)
Description copied from interface: PresenceChannelEventListener
Called when an existing user unsubscribes from the channel.

Specified by:
userUnsubscribed in interface PresenceChannelEventListener
Parameters:
channelName - The name of the channel that the user unsubscribed from.
user - The user who unsubscribed.

onEvent

public void onEvent(String channelName,
                    String eventName,
                    String data)
Description copied from interface: SubscriptionEventListener
Callback that is fired whenever an event that this SubscriptionEventListener has been bound to is received.

Specified by:
onEvent in interface SubscriptionEventListener
Parameters:
channelName - The name of the channel that the event has been received on. This is useful if your ChannelEventListener has been bound to events on more than one channel.
eventName - The name of the event that has been received. This will always be one of the events that your ChannelEventListener has been bound to.
data - The JSON data that was included with the event. This can be parsed with Google's Gson library, which is a dependency of this library, or your library of choice.

onSubscriptionSucceeded

public void onSubscriptionSucceeded(String channelName)
Description copied from interface: ChannelEventListener

Callback that is fired when a subscription success acknowledgement message is received from Pusher after subscribing to the channel.

For public channels this callback will be more or less immediate, assuming that you are connected to Pusher at the time of subscription. For private channels this callback will not be fired unless you are successfully authenticated.

Specified by:
onSubscriptionSucceeded in interface ChannelEventListener
Parameters:
channelName - The name of the channel that was successfully subscribed.

onAuthenticationFailure

public void onAuthenticationFailure(String message,
                                    Exception e)
Description copied from interface: PrivateChannelEventListener
Called when an attempt to authenticate a private channel fails.

Specified by:
onAuthenticationFailure in interface PrivateChannelEventListener
Parameters:
message - A description of the problem.
e - An associated exception, if available.


Copyright © 2013 Pusher. All Rights Reserved.