Options
Menu

Class Connection

A Connection represents a media and signaling connection to a TwiML application.

Hierarchy

  • EventEmitter
    • Connection

Index

Events

Static acceptEvent

Static audioEvent

  • audioEvent(remoteAudio: HTMLAudioElement): void
  • Emitted after the HTMLAudioElement for the remote audio is created.

    example

    connection.on('audio', handler(remoteAudio))

    Parameters

    • remoteAudio: HTMLAudioElement

      The HTMLAudioElement.

    Returns void

Static cancelEvent

  • cancelEvent(): void

Static disconnectEvent

Static errorEvent

  • errorEvent(error: Error): void

Static muteEvent

  • muteEvent(isMuted: boolean, connection: Connection): void

Static rejectEvent

Static sampleEvent

Static volumeEvent

  • volumeEvent(inputVolume: number, outputVolume: number): void
  • Emitted every 50ms with the current input and output volumes, as a percentage of maximum volume, between -100dB and -30dB. Represented by a floating point number.

    example

    connection.on('volume', (inputVolume, outputVolume) => { })

    Parameters

    • inputVolume: number

      A floating point number between 0.0 and 1.0 inclusive.

    • outputVolume: number

      A floating point number between 0.0 and 1.0 inclusive.

    Returns void

Properties

callerInfo

callerInfo: CallerInfo | null

Returns caller verification information about the caller. If no caller verification information is available this will return null.

customParameters

customParameters: Map<string, string>

The custom parameters sent to (outgoing) or received by (incoming) the TwiML app.

Private mediaStream

mediaStream: IPeerConnection

The MediaStream (Twilio PeerConnection) this Connection is using for media signaling.

Optional outboundConnectionId

outboundConnectionId: undefined | string

The temporary CallSid for this call, if it's outbound.

parameters

parameters: Record<string, string>

Call parameters received from Twilio for an incoming call.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

codec

  • get codec(): string

direction

Methods

Private _getRealCallSid

  • _getRealCallSid(): string | null
  • Get the real CallSid. Returns null if not present or is a temporary call sid.

    deprecated

    Returns string | null

Private _getTempCallSid

  • _getTempCallSid(): string | undefined

Private _setInputTracksFromStream

  • _setInputTracksFromStream(stream: MediaStream | null): Promise<void>
  • Set the audio input tracks from a given stream.

    Parameters

    • stream: MediaStream | null

    Returns Promise<void>

Private _setSinkIds

  • _setSinkIds(sinkIds: string[]): Promise<void>

accept

  • accept(audioConstraints?: MediaTrackConstraints | boolean, rtcConfiguration?: RTCConfiguration): void
  • accept(handler: function): void
  • Accept the incoming Connection.

    Parameters

    • Optional audioConstraints: MediaTrackConstraints | boolean
    • Optional rtcConfiguration: RTCConfiguration

    Returns void

  • deprecated

    Parameters

    • handler: function
        • (connection: this): void
        • Parameters

          • connection: this

          Returns void

    Returns void

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

cancel

  • cancel(): void
  • cancel(handler: function): void

disconnect

  • disconnect(): void
  • disconnect(handler: function): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

error

  • error(handler: function): void

eventNames

  • eventNames(): Array<string | symbol>

getLocalStream

  • getLocalStream(): MediaStream | undefined

getMaxListeners

  • getMaxListeners(): number

getRemoteStream

  • getRemoteStream(): MediaStream | undefined

ignore

  • ignore(): void
  • ignore(handler: function): void

isMuted

  • isMuted(): boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

mute

  • mute(shouldMute?: undefined | false | true): void
  • mute(handler: function): void
  • Mute incoming audio.

    Parameters

    • Optional shouldMute: undefined | false | true

      Whether the incoming audio should be muted. Defaults to true.

    Returns void

  • deprecated

    Parameters

    • handler: function
        • (isMuted: boolean, connection: this): void
        • Parameters

          • isMuted: boolean
          • connection: this

          Returns void

    Returns void

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

postFeedback

  • Post an event to Endpoint Analytics indicating that the end user has given call quality feedback. Called without a score, this will report that the customer declined to give feedback.

    Parameters

    • Optional score: FeedbackScore

      The end-user's rating of the call; an integer 1 through 5. Or undefined if the user declined to give feedback.

    • Optional issue: FeedbackIssue

      The primary issue the end user experienced on the call. Can be: ['one-way-audio', 'choppy-audio', 'dropped-call', 'audio-latency', 'noisy-call', 'echo']

    Returns Promise<void>

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

reject

  • reject(): void
  • reject(handler: function): void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

sendDigits

  • sendDigits(digits: string): void

setMaxListeners

  • setMaxListeners(n: number): this

status

Private toString

  • toString(): string

unmute

  • unmute(): void

volume

  • volume(handler: function): void
  • deprecated

    Parameters

    • handler: function
        • (inputVolume: number, outputVolume: number): void
        • Parameters

          • inputVolume: number
          • outputVolume: number

          Returns void

    Returns void

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static Private toString

  • toString(): string

Generated using TypeDoc