Options
Menu

Class Device

Twilio Device. Allows registration for incoming calls, and placing outgoing calls.

Hierarchy

  • EventEmitter
    • Device

Index

Type aliases

Static ToggleableSound

ToggleableSound: Incoming | Outgoing | Disconnect

Names of all togglable sounds.

Constructors

constructor

Events

Static cancelEvent

Static connectEvent

Static disconnectEvent

Static errorEvent

Static incomingEvent

Static offlineEvent

  • offlineEvent(device: Device): void

Static readyEvent

  • readyEvent(device: Device): void

Properties

audio

audio: AudioHelper | null = null

The AudioHelper instance associated with this Device.

connections

connections: Connection[] = []

An array of Connections. Though only one can be active, multiple may exist when there are multiple incoming, unanswered Connections.

isInitialized

isInitialized: boolean = false

Whether or not Device.setup has been called.

sounds

sounds: Partial<Record<SoundName, function>>

Methods to enable/disable each sound. Empty if the Device has not yet been set up.

token

token: string | null = null

The JWT string currently being used to authenticate this Device.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

edge

  • get edge(): string | null

Static Private audioContext

  • get audioContext(): AudioContext | undefined

Static Private extension

  • get extension(): "mp3" | "ogg"

Static isSupported

  • get isSupported(): boolean

Static packageName

  • get packageName(): string

Static version

  • get version(): string

Methods

activeConnection

  • activeConnection(): Connection | null | undefined

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(handler: function): this

connect

  • connect(params?: Record<string, string>, audioConstraints?: MediaTrackConstraints | boolean, rtcConfiguration?: RTCConfiguration): Connection
  • connect(handler: function): null
  • Make an outgoing Call.

    Parameters

    • Optional params: Record<string, string>
    • Optional audioConstraints: MediaTrackConstraints | boolean
    • Optional rtcConfiguration: RTCConfiguration

    Returns Connection

  • Add a listener for the connect event.

    Parameters

    • handler: function

      A handler to set on the connect event.

    Returns null

destroy

  • destroy(): void

disconnect

  • disconnect(handler: function): this

disconnectAll

  • disconnectAll(): void

emit

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

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

    Returns boolean

error

  • error(handler: function): this

eventNames

  • eventNames(): Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

incoming

  • incoming(handler: function): this

listenerCount

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

    • type: string | symbol

    Returns number

listeners

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

    • event: string | symbol

    Returns Function[]

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

offline

  • offline(handler: function): 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

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[]

ready

  • ready(handler: function): this

region

  • region(): string

registerPresence

  • registerPresence(): this

removeAllListeners

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

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: EventName, listener: function): this

setMaxListeners

  • setMaxListeners(n: number): this

setup

  • setup(token: string, options?: Options): this

status

Private toString

  • toString(): string

unregisterPresence

  • unregisterPresence(): this

updateToken

  • updateToken(token: string): void
  • Update the token and re-register.

    Parameters

    • token: string

      The new token JWT string to register with.

    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 runPreflight

Static Private toString

  • toString(): string

Generated using TypeDoc