ChannelGroup Entity
Since version 9.0.0, the Kotlin SDK supports entities, which are SDK objects that provide operations on endpoints associated with their type. They are designed as first-class citizens to facilitate working with various PubNub APIs.
Certain PubNub API functionality is already exposed via entities, while other may still be available using the pubnub
object.
Create ChannelGroup
This method returns one local ChannelGroup
entity.
pubnub.channelGroup(name: String): ChannelGroup
* required
Parameter | Description |
---|---|
name *Type: String | The name of a single channel group to create an entity for. |
Basic usage
Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
import com.pubnub.api.PubNub
import com.pubnub.api.UserId
import com.pubnub.api.v2.PNConfiguration
import com.pubnub.api.enums.PNLogVerbosity
fun main() {
println("PubNub ChannelGroup Entity Example")
println("=================================")
// 1. Configure PubNub
val userId = UserId("channel-group-entity-demo-user")
val config = PNConfiguration.builder(userId, "demo").apply {
publishKey = "demo"
subscribeKey = "demo"
logVerbosity = PNLogVerbosity.BODY // Enable debug logging
show all 54 linesAvailable operations
The ChannelGroup
entity provides operations performed on PubNub channel groups.
Operation (click for more information) | Description |
---|---|
subscription(subscriptionOptions) | Returns a local channel group subscription object with optional parameters to which you can subscribe and start receiving real-time updates for that channel group. |