Skip to main content

Class: Client

MoQ Publisher client that handles connection and serves ChannelProducer's tracks to subscribers.

Example

const client = new Client(config, channelProducer, namespace, timeSource)
client.connect()

// Later...
client.disconnect()
await client.closed()

Accessors

state

Get Signature

get state(): ConnectionState

Current connection state.

Returns

ConnectionState

Methods

closed()

closed(): Promise<Error | undefined>

Resolves when the client is fully closed.

Returns

Promise<Error | undefined>


connect()

connect(): void

Start publishing.

Returns

void


disconnect()

disconnect(): Promise<void>

Stop the connection and prevent reconnection.

Returns

Promise<void>


states()

states(): AsyncGenerator<ConnectionState, void, unknown>

Async iterator for state changes.

Returns

AsyncGenerator<ConnectionState, void, unknown>


updateAuthToken()

updateAuthToken(authToken): void

Update authentication token. Will be used for next connection attempt.

Parameters

authToken

string

Returns

void


waitFor()

waitFor(state): Promise<ConnectionState>

Wait for a specific connection state.

Parameters

state

ConnectionState

Returns

Promise<ConnectionState>