StreamId

class StreamId(val clientId: Short, val localStreamId: Short)(source)

Represents a unique ID for a stream.

This is commonly used when indicating which other streams should receive (or NOT receive) a broadcast message:

// Exclude from self:
ctx.stream.broadcastExcluding("Hello, everyone else!", ctx.stream.id)

As this class is simple, immutable data, it is totally safe to store a copy of it after receiving some event, e.g. if you receive a ClientConnected event, without worrying about major memory leaks. Just be sure to remove it when you receive a ClientDisconnected event that contains that stream ID.

In most cases, a user will only ever create a single client stream per API stream endpoint they want to connect to. However, a user could technically create multiple streams that attach to the same endpoint, and each one will get its own unique stream ID.

NOTE: A stream's ID is a hashed combination of its clientId and its localStreamId, which are both exposed as well.

Constructors

Link copied to clipboard
constructor(clientId: Short, localStreamId: Short)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A value which uniquely identifies the client that connected this stream. In most cases, users will only create one stream per endpoint, but in the case a user does create multiple streams, the client ID will be the same across all of them.

Link copied to clipboard

A value which uniquely identifies a stream for a client (but not globally across all clients). In other words, multiple different StreamId instances may share the same localStreamId but they will represent different streams if associated with different clientId values.

Link copied to clipboard
val value: Int

A value uniquely identifying this stream globally across all connected clients and all of their streams.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String