Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DefaultRealtimeController

DefaultRealtimeController is written to adhere to the following tenets to make privacy and performance bugs significantly less likely.

  1. Any call to the object is guaranteed to succeed from the caller's perspective to the maximum extent that this can be ensured. However, all failures of the object are reported as fatal errors. For example, if local mute fails, then that is a privacy issue and we must tear down the connection and try starting over.

  2. State is owned by the object and is considered authoritative at all times. For example, if realtimeIsLocalAudioMuted is true then the user is muted.

  3. Callbacks are fired synchronously and do their work synchronously. Any unnecessary asynchronous implementation only invites latency and increases the surface error for potential errors.

  4. Mutation only occurs when state changes. All state-changing functions are idempotent.

  5. Every conditional branch gets its own if statement and test coverage is 100% for this object.

  6. Function parameters and returns use primitives only (no classes or enums). This minimizes the number of dependencies that consumers have to take on and allows the object to be more easily wrapped. Values are normalized where possible.

  7. The object takes no other non-realtime dependencies.

  8. Interface functions begin with realtime to make boundaries between the RealtimeController interface and the UI or business logic explicit and auditable.

  9. Local state overrides remote state but not vice-versa. For example, if locally muted with an active audio input and a remote state indicates the same user is unmuted because the muted state has not yet propagated, then the volume indicator update for the user would show the remote mute state as muted. However, if locally muted without an active audio input and a remote state indicates the user is unmuted (since they are dialed in), the remote state persists but does not override the local state so realtimeIsLocalAudioMuted still returns true.

Hierarchy

  • DefaultRealtimeController

Implements

Index

Methods

realtimeCanUnmuteLocalAudio

  • realtimeCanUnmuteLocalAudio(): boolean

realtimeIsLocalAudioMuted

  • realtimeIsLocalAudioMuted(): boolean

realtimeMuteLocalAudio

  • realtimeMuteLocalAudio(): void

realtimeReceiveDataMessage

  • realtimeReceiveDataMessage(dataMessage: DataMessage): void

realtimeSendDataMessage

  • realtimeSendDataMessage(topic: string, data: Uint8Array | string | any, lifetimeMs?: number): void

realtimeSetAttendeeIdPresence

  • realtimeSetAttendeeIdPresence(attendeeId: string, present: boolean, externalUserId: string | null, dropped: boolean | null, posInFrame: RealtimeAttendeePositionInFrame | null): void

realtimeSetCanUnmuteLocalAudio

  • realtimeSetCanUnmuteLocalAudio(canUnmute: boolean): void

realtimeSetLocalAttendeeId

  • realtimeSetLocalAttendeeId(attendeeId: string, externalUserId: string): void

realtimeSetLocalAudioInput

  • realtimeSetLocalAudioInput(audioInput: MediaStream | null): void

realtimeSubscribeToAttendeeIdPresence

  • realtimeSubscribeToAttendeeIdPresence(callback: (attendeeId: string, present: boolean, externalUserId?: string, dropped?: boolean, posInFrame?: RealtimeAttendeePositionInFrame | null) => void): void

realtimeSubscribeToFatalError

  • realtimeSubscribeToFatalError(callback: (error: Error) => void): void

realtimeSubscribeToLocalSignalStrengthChange

  • realtimeSubscribeToLocalSignalStrengthChange(callback: (signalStrength: number) => void): void

realtimeSubscribeToMuteAndUnmuteLocalAudio

  • realtimeSubscribeToMuteAndUnmuteLocalAudio(callback: (muted: boolean) => void): void

realtimeSubscribeToReceiveDataMessage

  • realtimeSubscribeToReceiveDataMessage(topic: string, callback: (dataMessage: DataMessage) => void): void

realtimeSubscribeToSendDataMessage

  • realtimeSubscribeToSendDataMessage(callback: (topic: string, data: Uint8Array | string | any, lifetimeMs?: number) => void): void
  • Parameters

    • callback: (topic: string, data: Uint8Array | string | any, lifetimeMs?: number) => void
        • (topic: string, data: Uint8Array | string | any, lifetimeMs?: number): void
        • Parameters

          • topic: string
          • data: Uint8Array | string | any
          • Optional lifetimeMs: number

          Returns void

    Returns void

realtimeSubscribeToSetCanUnmuteLocalAudio

  • realtimeSubscribeToSetCanUnmuteLocalAudio(callback: (canUnmute: boolean) => void): void

realtimeSubscribeToVolumeIndicator

realtimeUnmuteLocalAudio

  • realtimeUnmuteLocalAudio(): boolean

realtimeUnsubscribeFromReceiveDataMessage

  • realtimeUnsubscribeFromReceiveDataMessage(topic: string): void

realtimeUnsubscribeFromSendDataMessage

  • realtimeUnsubscribeFromSendDataMessage(callback: (topic: string, data: Uint8Array | string | any, lifetimeMs?: number) => void): void
  • Parameters

    • callback: (topic: string, data: Uint8Array | string | any, lifetimeMs?: number) => void
        • (topic: string, data: Uint8Array | string | any, lifetimeMs?: number): void
        • Parameters

          • topic: string
          • data: Uint8Array | string | any
          • Optional lifetimeMs: number

          Returns void

    Returns void

realtimeUnsubscribeFromVolumeIndicator

realtimeUnsubscribeToAttendeeIdPresence

  • realtimeUnsubscribeToAttendeeIdPresence(callback: (attendeeId: string, present: boolean, externalUserId?: string, dropped?: boolean, posInFrame?: RealtimeAttendeePositionInFrame | null) => void): void

realtimeUnsubscribeToFatalError

  • realtimeUnsubscribeToFatalError(callback: (error: Error) => void): void

realtimeUnsubscribeToLocalSignalStrengthChange

  • realtimeUnsubscribeToLocalSignalStrengthChange(callback: (signalStrength: number) => void): void

realtimeUnsubscribeToMuteAndUnmuteLocalAudio

  • realtimeUnsubscribeToMuteAndUnmuteLocalAudio(callback: (muted: boolean) => void): void

realtimeUnsubscribeToSetCanUnmuteLocalAudio

  • realtimeUnsubscribeToSetCanUnmuteLocalAudio(callback: (canUnmute: boolean) => void): void

realtimeUpdateVolumeIndicator

  • realtimeUpdateVolumeIndicator(attendeeId: string, volume: number | null, muted: boolean | null, signalStrength: number | null, externalUserId: string | null): void

Generated using TypeDoc