com.pusher.client.channel.impl
Class ChannelImpl

java.lang.Object
  extended by com.pusher.client.channel.impl.ChannelImpl
All Implemented Interfaces:
Channel, InternalChannel, Comparable<InternalChannel>
Direct Known Subclasses:
PrivateChannelImpl

public class ChannelImpl
extends Object
implements InternalChannel


Field Summary
protected  Map<String,Set<SubscriptionEventListener>> eventNameToListenerMap
           
protected  String name
           
protected  ChannelState state
           
protected static String SUBSCRIPTION_SUCCESS_EVENT
           
 
Constructor Summary
ChannelImpl(String channelName)
           
 
Method Summary
 void bind(String eventName, SubscriptionEventListener listener)
          Binds a SubscriptionEventListener to an event.
 int compareTo(InternalChannel other)
           
protected  String[] getDisallowedNameExpressions()
           
 ChannelEventListener getEventListener()
           
 String getName()
          Gets the name of the Pusher channel that this object represents.
 void onMessage(String event, String message)
           
 void setEventListener(ChannelEventListener listener)
           
 String toString()
           
 String toSubscribeMessage()
           
 String toUnsubscribeMessage()
           
 void unbind(String eventName, SubscriptionEventListener listener)
          Unbinds a previously bound SubscriptionEventListener from an event.
 void updateState(ChannelState state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUBSCRIPTION_SUCCESS_EVENT

protected static final String SUBSCRIPTION_SUCCESS_EVENT
See Also:
Constant Field Values

name

protected final String name

eventNameToListenerMap

protected final Map<String,Set<SubscriptionEventListener>> eventNameToListenerMap

state

protected ChannelState state
Constructor Detail

ChannelImpl

public ChannelImpl(String channelName)
Method Detail

getName

public String getName()
Description copied from interface: Channel
Gets the name of the Pusher channel that this object represents.

Specified by:
getName in interface Channel
Returns:
The name of the channel.

bind

public void bind(String eventName,
                 SubscriptionEventListener listener)
Description copied from interface: Channel
Binds a SubscriptionEventListener to an event. The SubscriptionEventListener will be notified whenever the specified event is received on this channel.

Specified by:
bind in interface Channel
Parameters:
eventName - The name of the event to listen to.
listener - A listener to receive notifications when the event is received.

unbind

public void unbind(String eventName,
                   SubscriptionEventListener listener)
Description copied from interface: Channel

Unbinds a previously bound SubscriptionEventListener from an event. The SubscriptionEventListener will no longer be notified whenever the specified event is received on this channel.

Calling this method does not unsubscribe from the channel even if there are no more SubscriptionEventListeners bound to it. If you want to unsubscribe from the channel completely, call Pusher.unsubscribe(String). It is not necessary to unbind your SubscriptionEventListeners first.

Specified by:
unbind in interface Channel
Parameters:
eventName - The name of the event to stop listening to.
listener - The listener to unbind from the event.

onMessage

public void onMessage(String event,
                      String message)
Specified by:
onMessage in interface InternalChannel

toSubscribeMessage

public String toSubscribeMessage()
Specified by:
toSubscribeMessage in interface InternalChannel

toUnsubscribeMessage

public String toUnsubscribeMessage()
Specified by:
toUnsubscribeMessage in interface InternalChannel

updateState

public void updateState(ChannelState state)
Specified by:
updateState in interface InternalChannel

setEventListener

public void setEventListener(ChannelEventListener listener)
Specified by:
setEventListener in interface InternalChannel

getEventListener

public ChannelEventListener getEventListener()
Specified by:
getEventListener in interface InternalChannel

compareTo

public int compareTo(InternalChannel other)
Specified by:
compareTo in interface Comparable<InternalChannel>

toString

public String toString()
Overrides:
toString in class Object

getDisallowedNameExpressions

protected String[] getDisallowedNameExpressions()


Copyright © 2013 Pusher. All Rights Reserved.