SyncStream

interface SyncStream

Interface for Sync Pub-sub messaging primitive.

Message Stream is a Sync primitive for real-time pub-sub messaging. Stream Messages are not persisted, they exist only in transit, and will be dropped if (due to congestion or network anomalies) they cannot be delivered promptly.

You can publish Messages and listen for incoming Messages.

To obtain an instance of a SyncStream use SyncClient.streams.

Types

Link copied to clipboard
interface Events
Link copied to clipboard
data class Message(val sid: String, val data: <Error class: unknown class>)

Single message in a SyncStream.

Properties

Link copied to clipboard
abstract val dateExpires: <Error class: unknown class>?

A date this SyncStream will expire, null means will not expire.

Link copied to clipboard

Provides scope of Flows objects to get notified about events.

Link copied to clipboard

true when this SyncStream is offline and doesn't receive updates from backend, false otherwise.

Link copied to clipboard
abstract val isRemoved: Boolean

true when this SyncStream has been removed on the backend, false otherwise.

Link copied to clipboard
abstract val sid: EntitySid

An immutable system-assigned identifier of this SyncStream.

Link copied to clipboard

Current subscription state.

Link copied to clipboard
abstract val uniqueName: String?

An optional unique name for this stream, assigned at creation time.

Functions

Link copied to clipboard
abstract fun close()

Close this SyncStream.

Link copied to clipboard
abstract suspend fun publishMessage(data: <Error class: unknown class>): SyncStream.Message

Publish a new message to this SyncStream.

Link copied to clipboard
inline suspend fun <T : Any> SyncStream.publishMessage(data: T): SyncStream.Message

Serializes the given value into an equivalent JsonObject using a serializer retrieved from reified type parameter and publish it as a new message to this SyncStream.

Link copied to clipboard
abstract suspend fun removeStream()

Remove this SyncStream.

Link copied to clipboard
abstract suspend fun setTtl(ttl: <Error class: unknown class>)

Set time to live for this SyncStream.

Link copied to clipboard
inline fun <R> SyncStream.use(block: (SyncStream) -> R): R

Executes the given block function on SyncStream and then closes it down correctly whether an exception is thrown or not.