Subscription

Represents a potential subscription to the PubNub real-time network.

Create objects of this class through the com.pubnub.api.v2.entities.Subscribable.subscription method of the respective entities, such as com.pubnub.api.java.v2.entities.Channel, com.pubnub.api.java.v2.entities.ChannelGroup, com.pubnub.api.java.v2.entities.ChannelMetadata and com.pubnub.api.java.v2.entities.UserMetadata.

Created subscriptions are initially inactive, which means you must call subscribe to start receiving events.

This class implements the AutoCloseable interface to help you release resources by calling unsubscribe and removing all listeners on close. Remember to always call close when you no longer need this Subscription.

Functions

Link copied to clipboard
abstract fun addListener(listener: EventListener)

Add a listener.

Link copied to clipboard
abstract fun close()
Link copied to clipboard
abstract operator fun plus(subscription: Subscription): SubscriptionSet

Create a SubscriptionSet containing this Subscription and the added subscription.

Link copied to clipboard
abstract fun removeAllListeners()

Removes all listeners.

Link copied to clipboard
abstract fun removeListener(listener: Listener)

Remove a listener.

Link copied to clipboard
abstract fun setOnChannelMetadata(onChannelMetadataHandler: OnChannelMetadataHandler?)

Sets the handler for incoming channelMetadata events. This method allows the assignment of an OnChannelMetadataHandler implementation or lambda expression to handle incoming presence events.

Link copied to clipboard
abstract fun setOnFile(onFileHandler: OnFileHandler?)

Sets the handler for incoming file events. This method allows the assignment of an OnFileHandler implementation or lambda expression to handle incoming presence events.

Link copied to clipboard
abstract fun setOnMembership(onMembershipHandler: OnMembershipHandler?)

Sets the handler for incoming membership events. This method allows the assignment of an OnMembershipHandler implementation or lambda expression to handle incoming presence events.

Link copied to clipboard
abstract fun setOnMessage(onMessageHandler: OnMessageHandler?)

Sets the handler for incoming message events. This method allows the assignment of an OnMessageHandler implementation or lambda expression to handle incoming messages.

Link copied to clipboard
abstract fun setOnMessageAction(onMessageActionHandler: OnMessageActionHandler?)

Sets the handler for incoming messageAction events. This method allows the assignment of an OnMessageActionHandler implementation or lambda expression to handle incoming presence events.

Link copied to clipboard
abstract fun setOnPresence(onPresenceHandler: OnPresenceHandler?)

Sets the handler for incoming presence events. This method allows the assignment of an OnPresenceHandler implementation or lambda expression to handle incoming presence events.

Link copied to clipboard
abstract fun setOnSignal(onSignalHandler: OnSignalHandler?)

Sets the handler for incoming signal events. This method allows the assignment of an OnSignalHandler implementation or lambda expression to handle incoming signals.

Link copied to clipboard
abstract fun setOnUuidMetadata(onUuidMetadataHandler: OnUuidMetadataHandler?)

Sets the handler for incoming uuidMetadata events. This method allows the assignment of an OnUuidMetadataHandler implementation or lambda expression to handle incoming presence events.

Link copied to clipboard
abstract fun subscribe()

Start receiving events from the subscriptions (or subscriptions) represented by this object.

abstract fun subscribe(cursor: SubscriptionCursor)
Link copied to clipboard
abstract fun unsubscribe()