Channel 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 a Channel

This method returns one local Channel entity.

pubnub.channel(name: String): Channel
ParameterTypeRequiredDescription
nameStringYesThe name of a single channel to create a channel entity for.

Basic usage

val singleChannel = pubnub.channel("myChannel")

Available operations

The Channel entity provides operations performed on PubNub channels.

Operation (click for more information)Description
subscription(subscriptionOptions)Returns a local channel subscription object with optional parameters to which you can subscribe and start receiving real-time updates for that channel.
publish(message, shouldStore, meta, queryParam, usePost, ttl)Sends a message to all channel subscribers.
fire(message, meta, usePost)Sends a message to Illuminate and Functions event handlers registered on the channel and trigger their execution.
signal(message, meta, usePost)Sends a send a signal

Signal

A non-persistent message limited to 64 bytes designed for high-volume usecases where the the most recent data is relevant, like GPS location updates.
to all subscribers of a channel.
Last updated on