com.pubnub.api.builder.PubSub.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pubnub-kotlin Show documentation
Show all versions of pubnub-kotlin Show documentation
PubNub is a cross-platform client-to-client (1:1 and 1:many) push service in the cloud, capable of
broadcasting real-time messages to millions of web and mobile clients simultaneously, in less than a quarter
second!
package com.pubnub.api.builder
import com.pubnub.api.PubNub
import com.pubnub.api.managers.SubscriptionManager
object PubSub {
/**
* @see [PubNub.presence]
*/
internal fun presence(
subscriptionManager: SubscriptionManager,
channels: List = emptyList(),
channelGroups: List = emptyList(),
connected: Boolean = false
) {
val presenceOperation = PresenceOperation(
connected = connected,
channels = channels,
channelGroups = channelGroups
)
subscriptionManager.adaptPresenceBuilder(presenceOperation)
}
/**
* @see [PubNub.subscribe]
*/
internal fun subscribe(
subscriptionManager: SubscriptionManager,
channels: List = emptyList(),
channelGroups: List = emptyList(),
withPresence: Boolean = false,
withTimetoken: Long = 0L
) {
val subscribeOperation = SubscribeOperation(
channels = channels,
channelGroups = channelGroups,
presenceEnabled = withPresence,
timetoken = withTimetoken
)
subscriptionManager.adaptSubscribeBuilder(subscribeOperation)
}
/**
* @see [PubNub.unsubscribe]
*/
internal fun unsubscribe(
subscriptionManager: SubscriptionManager,
channels: List = emptyList(),
channelGroups: List = emptyList()
) {
val unsubscribeOperation = UnsubscribeOperation(
channels = channels,
channelGroups = channelGroups
)
subscriptionManager.adaptUnsubscribeBuilder(unsubscribeOperation)
}
}