Interface Channel
-
- All Known Subinterfaces:
PresenceChannel,PrivateChannel,PrivateEncryptedChannel
public interface Channel
An object that represents a Pusher channel. An implementation of this interface is returned when you callPusher.subscribe(String)orPusher.subscribe(String, ChannelEventListener, String...).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbind(java.lang.String eventName, SubscriptionEventListener listener)Binds aSubscriptionEventListenerto an event.voidbindGlobal(SubscriptionEventListener listener)Binds aSubscriptionEventListenerto all events.java.lang.StringgetName()Gets the name of the Pusher channel that this object represents.booleanisSubscribed()voidunbind(java.lang.String eventName, SubscriptionEventListener listener)Unbinds a previously boundSubscriptionEventListenerfrom an event.voidunbindGlobal(SubscriptionEventListener listener)Unbinds a previously boundSubscriptionEventListenerfrom global events.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Gets the name of the Pusher channel that this object represents.- Returns:
- The name of the channel.
-
bind
void bind(java.lang.String eventName, SubscriptionEventListener listener)
Binds aSubscriptionEventListenerto an event. TheSubscriptionEventListenerwill be notified whenever the specified event is received on this channel.- Parameters:
eventName- The name of the event to listen to.listener- A listener to receive notifications when the event is received.- Throws:
java.lang.IllegalArgumentException- If either of the following are true:- The name of the event is null.
- The
SubscriptionEventListeneris null.
java.lang.IllegalStateException- If the channel has been unsubscribed by callingPusher.unsubscribe(String). This puts the Channel in a terminal state from which it can no longer be used. To resubscribe, callPusher.subscribe(String)orPusher.subscribe(String, ChannelEventListener, String...)again to receive a fresh Channel instance.
-
bindGlobal
void bindGlobal(SubscriptionEventListener listener)
Binds aSubscriptionEventListenerto all events. TheSubscriptionEventListenerwill be notified whenever an event is received on this channel.- Parameters:
listener- A listener to receive notifications when the event is received.- Throws:
java.lang.IllegalArgumentException- If theSubscriptionEventListeneris null.java.lang.IllegalStateException- If the channel has been unsubscribed by callingPusher.unsubscribe(String). This puts the Channel in a terminal state from which it can no longer be used. To resubscribe, callPusher.subscribe(String)orPusher.subscribe(String, ChannelEventListener, String...)again to receive a fresh Channel instance.
-
unbind
void unbind(java.lang.String eventName, SubscriptionEventListener listener)
Unbinds a previously bound
SubscriptionEventListenerfrom an event. TheSubscriptionEventListenerwill 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, callPusher.unsubscribe(String). It is not necessary to unbind yourSubscriptionEventListeners first.- Parameters:
eventName- The name of the event to stop listening to.listener- The listener to unbind from the event.- Throws:
java.lang.IllegalArgumentException- If either of the following are true:- The name of the event is null.
- The
SubscriptionEventListeneris null.
java.lang.IllegalStateException- If the channel has been unsubscribed by callingPusher.unsubscribe(String). This puts the Channel in a terminal state from which it can no longer be used. To resubscribe, callPusher.subscribe(String)orPusher.subscribe(String, ChannelEventListener, String...)again to receive a fresh Channel instance.
-
unbindGlobal
void unbindGlobal(SubscriptionEventListener listener)
Unbinds a previously bound
SubscriptionEventListenerfrom global events. TheSubscriptionEventListenerwill no longer be notified whenever the any 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, callPusher.unsubscribe(String). It is not necessary to unbind yourSubscriptionEventListeners first.- Parameters:
listener- The listener to unbind from the event.- Throws:
java.lang.IllegalArgumentException- If theSubscriptionEventListeneris null.java.lang.IllegalStateException- If the channel has been unsubscribed by callingPusher.unsubscribe(String). This puts the Channel in a terminal state from which it can no longer be used. To resubscribe, callPusher.subscribe(String)orPusher.subscribe(String, ChannelEventListener, String...)again to receive a fresh Channel instance.
-
isSubscribed
boolean isSubscribed()
- Returns:
- Whether or not the channel is subscribed.
-
-