ari-client-plus
Version:
JavaScript client for Asterisk REST Interface.
1,853 lines (1,629 loc) • 227 kB
TypeScript
/// <reference types="node" />
/**
* Create an instance of Client using the provided connection options and call
* the provided callback once the API has been attached to the Client.
*
* @param baseUrl - The URL to the ARI instance.
* @param user - The username for the ARI instance.
* @param pass - The password for the ARI instance.
* @param [callback] - The callback to be called upon connection.
*/
export function connect(
baseUrl: string,
user: string,
pass: string,
options?: {
retryDelay?: number;
maxRetries?: number;
retryMaxDelay?: number;
},
callback?: (err: Error, client: Client) => void
): Promise<Client>;
/* This interface is kept for compatibility */
export interface TextMessageVariable {
key: string;
value: string;
}
export interface Client extends Resource {
/**
* Creates the WebSocket connection, subscribing to the given apps.
*
* @param apps - Name or array of names of the applications to be started.
* @param [subscribeAll] - Subscribe to all Asterisk events (true/false).
*/
start(apps: string | string[], subscribeAll?: boolean): Promise<void>;
/**
* Creates the WebSocket connection, subscribing to the given apps.
*
* @param apps - Name or array of names of the applications to be started.
* @param subscribeAll - Subscribe to all Asterisk events (true/false).
* @param callback - The callback to be called after applications have started.
*/
start(
apps: string | string[],
subscribeAll: boolean,
callback: (err: Error, ...args: any[]) => void
): void;
/**
* Creates the WebSocket connection, subscribing to the given apps.
*
* @param apps - Name or array of names of the applications to be started.
* @param callback - The callback to be called after applications have started.
*/
start(apps: string | string[], callback: (err: Error, ...args: any[]) => void): void;
/**
* Closes the WebSocket connection.
*/
stop(): void;
/**
* Pings the WebSocket.
*/
ping(): void;
/**
* Available Applications resources.
*/
applications: Applications;
/**
* Available Asterisk resource.
*/
asterisk: Asterisk;
/**
* Available Channels resources.
*/
channels: Channels;
/**
* Available Bridges resources.
*/
bridges: Bridges;
/**
* Available DeviceStates resources.
*/
deviceStates: DeviceStates;
/**
* Available Endpoints resources.
*/
endpoints: Endpoints;
/**
* Available Recordings resources.
*/
recordings: Recordings;
/**
* Available Mailboxes resources.
*/
mailboxes: Mailboxes;
/**
* Available Playbacks resources.
*/
playbacks: Playbacks;
/**
* Available Sounds resources.
*/
sounds: Sounds;
/**
* Available Events resources.
*/
events: Events;
/**
* Creates a new Application instance.
*/
Application(id?: string, objValues?: IndexableObject): Application;
/**
* Creates a new Asterisk instance.
*/
Asterisk(id?: string, objValues?: IndexableObject): Asterisk;
/**
* Creates a new Channel instance.
*/
Channel(id?: string, objValues?: IndexableObject): Channel;
/**
* Creates a new Bridge instance.
*/
Bridge(id?: string, objValues?: IndexableObject): Bridge;
/**
* Creates a new DeviceState instance.
*/
DeviceState(id?: string, objValues?: IndexableObject): DeviceState;
/**
* Creates a new Endpoint instance.
*/
Endpoint(id?: string, objValues?: IndexableObject): Endpoint;
/**
* Creates a new LiveRecording instance.
*/
LiveRecording(id?: string, objValues?: IndexableObject): LiveRecording;
/**
* Creates a new Mailbox instance.
*/
Mailbox(id?: string, objValues?: IndexableObject): Mailbox;
/**
* Creates a new Playback instance.
*/
Playback(id?: string, objValues?: IndexableObject): Playback;
/**
* Creates a new Sound instance.
*/
Sound(id?: string, objValues?: IndexableObject): Sound;
/**
* Creates a new StoredRecording instance.
*/
StoredRecording(id?: string, objValues?: IndexableObject): StoredRecording;
}
export interface Containers {
[key: string]: any;
}
export interface IndexableObject {
[key: string]: any;
}
/* Event Types */
export type WebSocketConnectedEventType = "WebSocketConnected";
export type WebSocketReconnectingEventType = "WebSocketReconnecting";
export type WebSocketMaxRetriesEventType = "WebSocketMaxRetries";
export type PongEventType = "pong";
export type APILoadErrorEventType = "APILoadError";
export type EventsEventType = "Events";
export type MessageEventType = "Message";
export type MissingParamsEventType = "MissingParams";
export type EventEventType = "Event";
export type ContactInfoEventType = "ContactInfo";
export type PeerEventType = "Peer";
export type DeviceStateChangedEventType = "DeviceStateChanged";
export type PlaybackStartedEventType = "PlaybackStarted";
export type PlaybackContinuingEventType = "PlaybackContinuing";
export type PlaybackFinishedEventType = "PlaybackFinished";
export type RecordingStartedEventType = "RecordingStarted";
export type RecordingFinishedEventType = "RecordingFinished";
export type RecordingFailedEventType = "RecordingFailed";
export type ApplicationMoveFailedEventType = "ApplicationMoveFailed";
export type ApplicationReplacedEventType = "ApplicationReplaced";
export type BridgeCreatedEventType = "BridgeCreated";
export type BridgeDestroyedEventType = "BridgeDestroyed";
export type BridgeMergedEventType = "BridgeMerged";
export type BridgeVideoSourceChangedEventType = "BridgeVideoSourceChanged";
export type BridgeBlindTransferEventType = "BridgeBlindTransfer";
export type BridgeAttendedTransferEventType = "BridgeAttendedTransfer";
export type ChannelCreatedEventType = "ChannelCreated";
export type ChannelDestroyedEventType = "ChannelDestroyed";
export type ChannelEnteredBridgeEventType = "ChannelEnteredBridge";
export type ChannelLeftBridgeEventType = "ChannelLeftBridge";
export type ChannelStateChangeEventType = "ChannelStateChange";
export type ChannelDtmfReceivedEventType = "ChannelDtmfReceived";
export type ChannelDialplanEventType = "ChannelDialplan";
export type ChannelCallerIdEventType = "ChannelCallerId";
export type ChannelUsereventEventType = "ChannelUserevent";
export type ChannelHangupRequestEventType = "ChannelHangupRequest";
export type ChannelVarsetEventType = "ChannelVarset";
export type ChannelHoldEventType = "ChannelHold";
export type ChannelUnholdEventType = "ChannelUnhold";
export type ChannelTalkingStartedEventType = "ChannelTalkingStarted";
export type ChannelTalkingFinishedEventType = "ChannelTalkingFinished";
export type ContactStatusChangeEventType = "ContactStatusChange";
export type PeerStatusChangeEventType = "PeerStatusChange";
export type EndpointStateChangeEventType = "EndpointStateChange";
export type DialEventType = "Dial";
export type StasisEndEventType = "StasisEnd";
export type StasisStartEventType = "StasisStart";
export type TextMessageReceivedEventType = "TextMessageReceived";
export type ChannelConnectedLineEventType = "ChannelConnectedLine";
export type AnyEventType =
| WebSocketConnectedEventType
| WebSocketReconnectingEventType
| WebSocketMaxRetriesEventType
| PongEventType
| APILoadErrorEventType
| EventsEventType
| MessageEventType
| MissingParamsEventType
| EventEventType
| ContactInfoEventType
| PeerEventType
| DeviceStateChangedEventType
| PlaybackStartedEventType
| PlaybackContinuingEventType
| PlaybackFinishedEventType
| RecordingStartedEventType
| RecordingFinishedEventType
| RecordingFailedEventType
| ApplicationMoveFailedEventType
| ApplicationReplacedEventType
| BridgeCreatedEventType
| BridgeDestroyedEventType
| BridgeMergedEventType
| BridgeVideoSourceChangedEventType
| BridgeBlindTransferEventType
| BridgeAttendedTransferEventType
| ChannelCreatedEventType
| ChannelDestroyedEventType
| ChannelEnteredBridgeEventType
| ChannelLeftBridgeEventType
| ChannelStateChangeEventType
| ChannelDtmfReceivedEventType
| ChannelDialplanEventType
| ChannelCallerIdEventType
| ChannelUsereventEventType
| ChannelHangupRequestEventType
| ChannelVarsetEventType
| ChannelHoldEventType
| ChannelUnholdEventType
| ChannelTalkingStartedEventType
| ChannelTalkingFinishedEventType
| ContactStatusChangeEventType
| PeerStatusChangeEventType
| EndpointStateChangeEventType
| DialEventType
| StasisEndEventType
| StasisStartEventType
| TextMessageReceivedEventType
| ChannelConnectedLineEventType;
/* Event Classes */
export interface Events {
/**
* WebSocket connection for events.
*
* @param params.app - Applications to subscribe to.
* @param [params.subscribeAll] - Subscribe to all Asterisk events. If provided, the applications listed will be subscribed to all events, effectively disabling the application specific
* subscriptions. Default is false.
*/
eventWebsocket(
params: { app: string | string[]; subscribeAll?: boolean | undefined },
callback: (err: Error, message: Message) => void
): void;
/**
* WebSocket connection for events.
*
* @param params.app - Applications to subscribe to.
* @param [params.subscribeAll] - Subscribe to all Asterisk events. If provided, the applications listed will be subscribed to all events, effectively disabling the application specific
* subscriptions. Default is false.
*/
eventWebsocket(params: {
app: string | string[];
subscribeAll?: boolean | undefined;
}): Promise<Message>;
/**
* Generate a user event.
*
* @param params.eventName - Event name.
* @param params.application - The name of the application that will receive this event.
* @param [params.source] - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName}.
* @param [params.variables] - The "variables" key in the body object holds custom key/value pairs to add to the user event. Ex. { "variables": { "key": "value" } }.
*/
userEvent(
params: {
eventName: string;
application: string;
source?: string | string[] | undefined;
variables?: Containers | undefined;
},
callback: (err: Error) => void
): void;
/**
* Generate a user event.
*
* @param params.eventName - Event name.
* @param params.application - The name of the application that will receive this event.
* @param [params.source] - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName}.
* @param [params.variables] - The "variables" key in the body object holds custom key/value pairs to add to the user event. Ex. { "variables": { "key": "value" } }.
*/
userEvent(params: {
eventName: string;
application: string;
source?: string | string[] | undefined;
variables?: Containers | undefined;
}): Promise<void>;
}
export interface Message {
/**
* Indicates the type of this message.
*/
type: string;
/**
* The unique ID for the Asterisk instance that raised this event.
*/
asterisk_id?: string | undefined;
}
export interface MissingParams extends Message {
/**
* A list of the missing parameters.
*/
params: string | string[];
}
export interface Event extends Message {
/**
* Name of the application receiving the event.
*/
application: string;
/**
* ISO 8601 date/time at which this event was created.
*/
timestamp: string;
}
export interface ContactInfo {
/**
* The location of the contact.
*/
uri: string;
/**
* The current status of the contact.
*/
contact_status: string;
/**
* The Address of Record this contact belongs to.
*/
aor: string;
/**
* Current round trip time, in microseconds, for the contact.
*/
roundtrip_usec?: string | undefined;
}
export interface Peer {
/**
* The current state of the peer. Note that the values of the status are dependent on the underlying peer technology.
*/
peer_status: string;
/**
* An optional reason associated with the change in peer_status.
*/
cause?: string | undefined;
/**
* The IP address of the peer.
*/
address?: string | undefined;
/**
* The port of the peer.
*/
port?: string | undefined;
/**
* The last known time the peer was contacted.
*/
time?: string | undefined;
}
export interface DeviceStateChanged extends Event {
/**
* Device state object.
*/
device_state: DeviceState;
}
export interface PlaybackStarted extends Event {
/**
* Playback control object.
*/
playback: Playback;
}
export interface PlaybackContinuing extends Event {
/**
* Playback control object.
*/
playback: Playback;
}
export interface PlaybackFinished extends Event {
/**
* Playback control object.
*/
playback: Playback;
}
export interface RecordingStarted extends Event {
/**
* Recording control object.
*/
recording: LiveRecording;
}
export interface RecordingFinished extends Event {
/**
* Recording control object.
*/
recording: LiveRecording;
}
export interface RecordingFailed extends Event {
/**
* Recording control object.
*/
recording: LiveRecording;
}
export interface ApplicationMoveFailed extends Event {
/**
* Channel.
*/
channel: Channel;
/**
* Destination.
*/
destination: string;
/**
* Arguments to the application.
*/
args: string | string[];
}
export interface BridgeCreated extends Event {
/**
* Bridge.
*/
bridge: Bridge;
}
export interface BridgeDestroyed extends Event {
/**
* Bridge.
*/
bridge: Bridge;
}
export interface BridgeMerged extends Event {
/**
* Bridge.
*/
bridge: Bridge;
/**
* Bridge_from.
*/
bridge_from: Bridge;
}
export interface BridgeVideoSourceChanged extends Event {
/**
* Bridge.
*/
bridge: Bridge;
/**
* Old_video_source_id.
*/
old_video_source_id?: string | undefined;
}
export interface BridgeBlindTransfer extends Event {
/**
* The channel performing the blind transfer.
*/
channel: Channel;
/**
* The channel that is replacing transferer when the transferee(s) can not be transferred directly.
*/
replace_channel?: Channel | undefined;
/**
* The channel that is being transferred.
*/
transferee?: Channel | undefined;
/**
* The extension transferred to.
*/
exten: string;
/**
* The context transferred to.
*/
context: string;
/**
* The result of the transfer attempt.
*/
result: string;
/**
* Whether the transfer was externally initiated or not.
*/
is_external: boolean;
/**
* The bridge being transferred.
*/
bridge: Bridge;
}
export interface BridgeAttendedTransfer extends Event {
/**
* First leg of the transferer.
*/
transferer_first_leg: Channel;
/**
* Second leg of the transferer.
*/
transferer_second_leg: Channel;
/**
* The channel that is replacing transferer_first_leg in the swap.
*/
replace_channel?: Channel | undefined;
/**
* The channel that is being transferred.
*/
transferee?: Channel | undefined;
/**
* The channel that is being transferred to.
*/
transfer_target?: Channel | undefined;
/**
* The result of the transfer attempt.
*/
result: string;
/**
* Whether the transfer was externally initiated or not.
*/
is_external: boolean;
/**
* Bridge the transferer first leg is in.
*/
transferer_first_leg_bridge: Bridge;
/**
* Bridge the transferer second leg is in.
*/
transferer_second_leg_bridge: Bridge;
/**
* How the transfer was accomplished.
*/
destination_type: string;
/**
* Bridge that survived the merge result.
*/
destination_bridge: string;
/**
* Application that has been transferred into.
*/
destination_application: string;
/**
* First leg of a link transfer result.
*/
destination_link_first_leg: Channel;
/**
* Second leg of a link transfer result.
*/
destination_link_second_leg: Channel;
/**
* Transferer channel that survived the threeway result.
*/
destination_threeway_channel: Channel;
/**
* Bridge that survived the threeway result.
*/
destination_threeway_bridge: Bridge;
}
export interface ChannelCreated extends Event {
/**
* Channel.
*/
channel: Channel;
}
export interface ChannelDestroyed extends Event {
/**
* Integer representation of the cause of the hangup.
*/
cause: number;
/**
* Text representation of the cause of the hangup.
*/
cause_txt: string;
/**
* Channel.
*/
channel: Channel;
}
export interface ChannelEnteredBridge extends Event {
/**
* Bridge.
*/
bridge: Bridge;
/**
* Channel.
*/
channel: Channel;
}
export interface ChannelLeftBridge extends Event {
/**
* Bridge.
*/
bridge: Bridge;
/**
* Channel.
*/
channel: Channel;
}
export interface ChannelStateChange extends Event {
/**
* Channel.
*/
channel: Channel;
}
export interface ChannelDtmfReceived extends Event {
/**
* DTMF digit received (0-9, A-E, # or *).
*/
digit: string;
/**
* Number of milliseconds DTMF was received.
*/
duration_ms: number;
/**
* The channel on which DTMF was received.
*/
channel: Channel;
}
export interface ChannelDialplan extends Event {
/**
* The channel that changed dialplan location.
*/
channel: Channel;
/**
* The application about to be executed.
*/
dialplan_app: string;
/**
* The data to be passed to the application.
*/
dialplan_app_data: string;
}
export interface ChannelCallerId extends Event {
/**
* The integer representation of the Caller Presentation value.
*/
caller_presentation: number;
/**
* The text representation of the Caller Presentation value.
*/
caller_presentation_txt: string;
/**
* The channel that changed Caller ID.
*/
channel: Channel;
}
export interface ChannelUserevent extends Event {
/**
* The name of the user event.
*/
eventname: string;
/**
* A channel that is signaled with the user event.
*/
channel?: Channel | undefined;
/**
* A bridge that is signaled with the user event.
*/
bridge?: Bridge | undefined;
/**
* A endpoint that is signaled with the user event.
*/
endpoint?: Endpoint | undefined;
/**
* Custom Userevent data.
*/
userevent: IndexableObject;
}
export interface ChannelHangupRequest extends Event {
/**
* Integer representation of the cause of the hangup.
*/
cause: number;
/**
* Whether the hangup request was a soft hangup request.
*/
soft: boolean;
/**
* The channel on which the hangup was requested.
*/
channel: Channel;
}
export interface ChannelVarset extends Event {
/**
* The variable that changed.
*/
variable: string;
/**
* The new value of the variable.
*/
value: string;
/**
* The channel on which the variable was set. If missing, the variable is a global variable.
*/
channel?: Channel | undefined;
}
export interface ChannelHold extends Event {
/**
* The channel that initiated the hold event.
*/
channel: Channel;
/**
* The music on hold class that the initiator requested.
*/
musicclass?: string | undefined;
}
export interface ChannelUnhold extends Event {
/**
* The channel that initiated the unhold event.
*/
channel: Channel;
}
export interface ChannelTalkingStarted extends Event {
/**
* The channel on which talking started.
*/
channel: Channel;
}
export interface ChannelTalkingFinished extends Event {
/**
* The channel on which talking completed.
*/
channel: Channel;
/**
* The length of time, in milliseconds, that talking was detected on the channel.
*/
duration: number;
}
export interface ContactStatusChange extends Event {
/**
* Endpoint.
*/
endpoint: Endpoint;
/**
* Contact_info.
*/
contact_info: ContactInfo;
}
export interface PeerStatusChange extends Event {
/**
* Endpoint.
*/
endpoint: Endpoint;
/**
* Peer.
*/
peer: Peer;
}
export interface EndpointStateChange extends Event {
/**
* Endpoint.
*/
endpoint: Endpoint;
}
export interface Dial extends Event {
/**
* The calling channel.
*/
caller?: Channel | undefined;
/**
* The dialed channel.
*/
peer: Channel;
/**
* Forwarding target requested by the original dialed channel.
*/
forward?: string | undefined;
/**
* Channel that the caller has been forwarded to.
*/
forwarded?: Channel | undefined;
/**
* The dial string for calling the peer channel.
*/
dialstring?: string | undefined;
/**
* Current status of the dialing attempt to the peer.
*/
dialstatus: string;
}
export interface StasisEnd extends Event {
/**
* Channel.
*/
channel: Channel;
}
export interface StasisStart extends Event {
/**
* Arguments to the application.
*/
args: string | string[];
/**
* Channel.
*/
channel: Channel;
/**
* Replace_channel.
*/
replace_channel?: Channel | undefined;
}
export interface TextMessageReceived extends Event {
/**
* Message.
*/
message: TextMessage;
/**
* Endpoint.
*/
endpoint?: Endpoint | undefined;
}
export interface ChannelConnectedLine extends Event {
/**
* The channel whose connected line has changed.
*/
channel: Channel;
}
export interface Resource {
/**
* The ARI client instance.
*/
_client: Client;
/**
* Error emitted when WebSocket reconnection attempts exceeded MaxRetries.
*/
// tslint:disable-next-line:unified-signatures
on(type: WebSocketMaxRetriesEventType, listener: (err: Error) => void): void;
/**
* Error emitted when the WebSocket is reconnecting.
*/
// tslint:disable-next-line:unified-signatures
on(type: WebSocketReconnectingEventType, listener: (err: Error) => void): void;
/**
* Event emitted when the WebSocket is connected.
*/
// tslint:disable-next-line:unified-signatures
on(type: WebSocketConnectedEventType, listener: () => void): void;
/**
* Event emitted when a WebSocket pong is received.
*/
// tslint:disable-next-line:unified-signatures
on(type: PongEventType, listener: () => void): void;
/**
* Error event sent when connection to API fails.
*/
// tslint:disable-next-line:unified-signatures
on(type: APILoadErrorEventType, listener: (err: Error) => void): void;
/**
* Base type for errors and events.
*/
on(event: MessageEventType, callback: (event: Message, instances: Message) => void): void;
/**
* Error event sent when required params are missing.
*/
on(
event: MissingParamsEventType,
callback: (event: MissingParams, instances: MissingParams) => void
): void;
/**
* Base type for asynchronous events from Asterisk.
*/
on(event: EventEventType, callback: (event: Event, instances: Event) => void): void;
/**
* Detailed information about a contact on an endpoint.
*/
on(
event: ContactInfoEventType,
callback: (event: ContactInfo, instances: ContactInfo) => void
): void;
/**
* Detailed information about a remote peer that communicates with Asterisk.
*/
on(event: PeerEventType, callback: (event: Peer, instances: Peer) => void): void;
/**
* Notification that a device state has changed.
*/
on(
event: DeviceStateChangedEventType,
callback: (event: DeviceStateChanged, devicestate: DeviceState) => void
): void;
/**
* Event showing the start of a media playback operation.
*/
on(
event: PlaybackStartedEventType,
callback: (event: PlaybackStarted, playback: Playback) => void
): void;
/**
* Event showing the continuation of a media playback operation from one media URI to the next in the list.
*/
on(
event: PlaybackContinuingEventType,
callback: (event: PlaybackContinuing, playback: Playback) => void
): void;
/**
* Event showing the completion of a media playback operation.
*/
on(
event: PlaybackFinishedEventType,
callback: (event: PlaybackFinished, playback: Playback) => void
): void;
/**
* Event showing the start of a recording operation.
*/
on(
event: RecordingStartedEventType,
callback: (event: RecordingStarted, liverecording: LiveRecording) => void
): void;
/**
* Event showing the completion of a recording operation.
*/
on(
event: RecordingFinishedEventType,
callback: (event: RecordingFinished, liverecording: LiveRecording) => void
): void;
/**
* Event showing failure of a recording operation.
*/
on(
event: RecordingFailedEventType,
callback: (event: RecordingFailed, liverecording: LiveRecording) => void
): void;
/**
* Notification that trying to move a channel to another Stasis application failed.
*/
on(
event: ApplicationMoveFailedEventType,
callback: (event: ApplicationMoveFailed, channel: Channel) => void
): void;
/**
* Notification that another WebSocket has taken over for an application. An application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe
* to the same application, the newer WebSocket wins, and the older one receives this event.
*/
on(event: ApplicationReplacedEventType, callback: (event: Event) => void): void;
/**
* Notification that a bridge has been created.
*/
on(
event: BridgeCreatedEventType,
callback: (event: BridgeCreated, bridge: Bridge) => void
): void;
/**
* Notification that a bridge has been destroyed.
*/
on(
event: BridgeDestroyedEventType,
callback: (event: BridgeDestroyed, bridge: Bridge) => void
): void;
/**
* Notification that one bridge has merged into another.
*/
on(event: BridgeMergedEventType, callback: (event: BridgeMerged, bridge: Bridge) => void): void;
/**
* Notification that the source of video in a bridge has changed.
*/
on(
event: BridgeVideoSourceChangedEventType,
callback: (event: BridgeVideoSourceChanged, bridge: Bridge) => void
): void;
/**
* Notification that a blind transfer has occurred.
*/
on(
event: BridgeBlindTransferEventType,
callback: (event: BridgeBlindTransfer, instances: BridgeBlindTransfer) => void
): void;
/**
* Notification that an attended transfer has occurred.
*/
on(
event: BridgeAttendedTransferEventType,
callback: (event: BridgeAttendedTransfer, instances: BridgeAttendedTransfer) => void
): void;
/**
* Notification that a channel has been created.
*/
on(
event: ChannelCreatedEventType,
callback: (event: ChannelCreated, channel: Channel) => void
): void;
/**
* Notification that a channel has been destroyed.
*/
on(
event: ChannelDestroyedEventType,
callback: (event: ChannelDestroyed, channel: Channel) => void
): void;
/**
* Notification that a channel has entered a bridge.
*/
on(
event: ChannelEnteredBridgeEventType,
callback: (event: ChannelEnteredBridge, instances: ChannelEnteredBridge) => void
): void;
/**
* Notification that a channel has left a bridge.
*/
on(
event: ChannelLeftBridgeEventType,
callback: (event: ChannelLeftBridge, instances: ChannelLeftBridge) => void
): void;
/**
* Notification of a channels state change.
*/
on(
event: ChannelStateChangeEventType,
callback: (event: ChannelStateChange, channel: Channel) => void
): void;
/**
* DTMF received on a channel. This event is sent when the DTMF ends. There is no notification about the start of DTMF.
*/
on(
event: ChannelDtmfReceivedEventType,
callback: (event: ChannelDtmfReceived, channel: Channel) => void
): void;
/**
* Channel changed location in the dialplan.
*/
on(
event: ChannelDialplanEventType,
callback: (event: ChannelDialplan, channel: Channel) => void
): void;
/**
* Channel changed Caller ID.
*/
on(
event: ChannelCallerIdEventType,
callback: (event: ChannelCallerId, channel: Channel) => void
): void;
/**
* User-generated event with additional user-defined fields in the object.
*/
on(
event: ChannelUsereventEventType,
callback: (event: ChannelUserevent, instances: ChannelUserevent) => void
): void;
/**
* A hangup was requested on the channel.
*/
on(
event: ChannelHangupRequestEventType,
callback: (event: ChannelHangupRequest, channel: Channel) => void
): void;
/**
* Channel variable changed.
*/
on(
event: ChannelVarsetEventType,
callback: (event: ChannelVarset, channel: Channel) => void
): void;
/**
* A channel initiated a media hold.
*/
on(event: ChannelHoldEventType, callback: (event: ChannelHold, channel: Channel) => void): void;
/**
* A channel initiated a media unhold.
*/
on(
event: ChannelUnholdEventType,
callback: (event: ChannelUnhold, channel: Channel) => void
): void;
/**
* Talking was detected on the channel.
*/
on(
event: ChannelTalkingStartedEventType,
callback: (event: ChannelTalkingStarted, channel: Channel) => void
): void;
/**
* Talking is no longer detected on the channel.
*/
on(
event: ChannelTalkingFinishedEventType,
callback: (event: ChannelTalkingFinished, channel: Channel) => void
): void;
/**
* The state of a contact on an endpoint has changed.
*/
on(
event: ContactStatusChangeEventType,
callback: (event: ContactStatusChange, endpoint: Endpoint) => void
): void;
/**
* The state of a peer associated with an endpoint has changed.
*/
on(
event: PeerStatusChangeEventType,
callback: (event: PeerStatusChange, endpoint: Endpoint) => void
): void;
/**
* Endpoint state changed.
*/
on(
event: EndpointStateChangeEventType,
callback: (event: EndpointStateChange, endpoint: Endpoint) => void
): void;
/**
* Dialing state has changed.
*/
on(event: DialEventType, callback: (event: Dial, channel: Channel) => void): void;
/**
* Notification that a channel has left a Stasis application.
*/
on(event: StasisEndEventType, callback: (event: StasisEnd, channel: Channel) => void): void;
/**
* Notification that a channel has entered a Stasis application.
*/
on(event: StasisStartEventType, callback: (event: StasisStart, channel: Channel) => void): void;
/**
* A text message was received from an endpoint.
*/
on(
event: TextMessageReceivedEventType,
callback: (event: TextMessageReceived, endpoint: Endpoint) => void
): void;
/**
* Channel changed Connected Line.
*/
on(
event: ChannelConnectedLineEventType,
callback: (event: ChannelConnectedLine, channel: Channel) => void
): void;
/**
* Error emitted when WebSocket reconnection attempts exceeded MaxRetries.
*/
// tslint:disable-next-line:unified-signatures
once(type: WebSocketMaxRetriesEventType, listener: (err: Error) => void): void;
/**
* Error emitted when the WebSocket is reconnecting.
*/
// tslint:disable-next-line:unified-signatures
once(type: WebSocketReconnectingEventType, listener: (err: Error) => void): void;
/**
* Event emitted when the WebSocket is connected.
*/
// tslint:disable-next-line:unified-signatures
once(type: WebSocketConnectedEventType, listener: () => void): void;
/**
* Event emitted when a WebSocket pong is received.
*/
// tslint:disable-next-line:unified-signatures
once(type: PongEventType, listener: () => void): void;
/**
* Error event sent when connection to API fails.
*/
// tslint:disable-next-line:unified-signatures
once(type: APILoadErrorEventType, listener: (err: Error) => void): void;
/**
* Base type for errors and events.
*/
once(event: MessageEventType, callback: (event: Message, instances: Message) => void): void;
/**
* Error event sent when required params are missing.
*/
once(
event: MissingParamsEventType,
callback: (event: MissingParams, instances: MissingParams) => void
): void;
/**
* Base type for asynchronous events from Asterisk.
*/
once(event: EventEventType, callback: (event: Event, instances: Event) => void): void;
/**
* Detailed information about a contact on an endpoint.
*/
once(
event: ContactInfoEventType,
callback: (event: ContactInfo, instances: ContactInfo) => void
): void;
/**
* Detailed information about a remote peer that communicates with Asterisk.
*/
once(event: PeerEventType, callback: (event: Peer, instances: Peer) => void): void;
/**
* Notification that a device state has changed.
*/
once(
event: DeviceStateChangedEventType,
callback: (event: DeviceStateChanged, devicestate: DeviceState) => void
): void;
/**
* Event showing the start of a media playback operation.
*/
once(
event: PlaybackStartedEventType,
callback: (event: PlaybackStarted, playback: Playback) => void
): void;
/**
* Event showing the continuation of a media playback operation from one media URI to the next in the list.
*/
once(
event: PlaybackContinuingEventType,
callback: (event: PlaybackContinuing, playback: Playback) => void
): void;
/**
* Event showing the completion of a media playback operation.
*/
once(
event: PlaybackFinishedEventType,
callback: (event: PlaybackFinished, playback: Playback) => void
): void;
/**
* Event showing the start of a recording operation.
*/
once(
event: RecordingStartedEventType,
callback: (event: RecordingStarted, liverecording: LiveRecording) => void
): void;
/**
* Event showing the completion of a recording operation.
*/
once(
event: RecordingFinishedEventType,
callback: (event: RecordingFinished, liverecording: LiveRecording) => void
): void;
/**
* Event showing failure of a recording operation.
*/
once(
event: RecordingFailedEventType,
callback: (event: RecordingFailed, liverecording: LiveRecording) => void
): void;
/**
* Notification that trying to move a channel to another Stasis application failed.
*/
once(
event: ApplicationMoveFailedEventType,
callback: (event: ApplicationMoveFailed, channel: Channel) => void
): void;
/**
* Notification that another WebSocket has taken over for an application. An application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe
* to the same application, the newer WebSocket wins, and the older one receives this event.
*/
once(event: ApplicationReplacedEventType, callback: (event: Event) => void): void;
/**
* Notification that a bridge has been created.
*/
once(
event: BridgeCreatedEventType,
callback: (event: BridgeCreated, bridge: Bridge) => void
): void;
/**
* Notification that a bridge has been destroyed.
*/
once(
event: BridgeDestroyedEventType,
callback: (event: BridgeDestroyed, bridge: Bridge) => void
): void;
/**
* Notification that one bridge has merged into another.
*/
once(
event: BridgeMergedEventType,
callback: (event: BridgeMerged, bridge: Bridge) => void
): void;
/**
* Notification that the source of video in a bridge has changed.
*/
once(
event: BridgeVideoSourceChangedEventType,
callback: (event: BridgeVideoSourceChanged, bridge: Bridge) => void
): void;
/**
* Notification that a blind transfer has occurred.
*/
once(
event: BridgeBlindTransferEventType,
callback: (event: BridgeBlindTransfer, instances: BridgeBlindTransfer) => void
): void;
/**
* Notification that an attended transfer has occurred.
*/
once(
event: BridgeAttendedTransferEventType,
callback: (event: BridgeAttendedTransfer, instances: BridgeAttendedTransfer) => void
): void;
/**
* Notification that a channel has been created.
*/
once(
event: ChannelCreatedEventType,
callback: (event: ChannelCreated, channel: Channel) => void
): void;
/**
* Notification that a channel has been destroyed.
*/
once(
event: ChannelDestroyedEventType,
callback: (event: ChannelDestroyed, channel: Channel) => void
): void;
/**
* Notification that a channel has entered a bridge.
*/
once(
event: ChannelEnteredBridgeEventType,
callback: (event: ChannelEnteredBridge, instances: ChannelEnteredBridge) => void
): void;
/**
* Notification that a channel has left a bridge.
*/
once(
event: ChannelLeftBridgeEventType,
callback: (event: ChannelLeftBridge, instances: ChannelLeftBridge) => void
): void;
/**
* Notification of a channels state change.
*/
once(
event: ChannelStateChangeEventType,
callback: (event: ChannelStateChange, channel: Channel) => void
): void;
/**
* DTMF received on a channel. This event is sent when the DTMF ends. There is no notification about the start of DTMF.
*/
once(
event: ChannelDtmfReceivedEventType,
callback: (event: ChannelDtmfReceived, channel: Channel) => void
): void;
/**
* Channel changed location in the dialplan.
*/
once(
event: ChannelDialplanEventType,
callback: (event: ChannelDialplan, channel: Channel) => void
): void;
/**
* Channel changed Caller ID.
*/
once(
event: ChannelCallerIdEventType,
callback: (event: ChannelCallerId, channel: Channel) => void
): void;
/**
* User-generated event with additional user-defined fields in the object.
*/
once(
event: ChannelUsereventEventType,
callback: (event: ChannelUserevent, instances: ChannelUserevent) => void
): void;
/**
* A hangup was requested on the channel.
*/
once(
event: ChannelHangupRequestEventType,
callback: (event: ChannelHangupRequest, channel: Channel) => void
): void;
/**
* Channel variable changed.
*/
once(
event: ChannelVarsetEventType,
callback: (event: ChannelVarset, channel: Channel) => void
): void;
/**
* A channel initiated a media hold.
*/
once(
event: ChannelHoldEventType,
callback: (event: ChannelHold, channel: Channel) => void
): void;
/**
* A channel initiated a media unhold.
*/
once(
event: ChannelUnholdEventType,
callback: (event: ChannelUnhold, channel: Channel) => void
): void;
/**
* Talking was detected on the channel.
*/
once(
event: ChannelTalkingStartedEventType,
callback: (event: ChannelTalkingStarted, channel: Channel) => void
): void;
/**
* Talking is no longer detected on the channel.
*/
once(
event: ChannelTalkingFinishedEventType,
callback: (event: ChannelTalkingFinished, channel: Channel) => void
): void;
/**
* The state of a contact on an endpoint has changed.
*/
once(
event: ContactStatusChangeEventType,
callback: (event: ContactStatusChange, endpoint: Endpoint) => void
): void;
/**
* The state of a peer associated with an endpoint has changed.
*/
once(
event: PeerStatusChangeEventType,
callback: (event: PeerStatusChange, endpoint: Endpoint) => void
): void;
/**
* Endpoint state changed.
*/
once(
event: EndpointStateChangeEventType,
callback: (event: EndpointStateChange, endpoint: Endpoint) => void
): void;
/**
* Dialing state has changed.
*/
once(event: DialEventType, callback: (event: Dial, channel: Channel) => void): void;
/**
* Notification that a channel has left a Stasis application.
*/
once(event: StasisEndEventType, callback: (event: StasisEnd, channel: Channel) => void): void;
/**
* Notification that a channel has entered a Stasis application.
*/
once(
event: StasisStartEventType,
callback: (event: StasisStart, channel: Channel) => void
): void;
/**
* A text message was received from an endpoint.
*/
once(
event: TextMessageReceivedEventType,
callback: (event: TextMessageReceived, endpoint: Endpoint) => void
): void;
/**
* Channel changed Connected Line.
*/
once(
event: ChannelConnectedLineEventType,
callback: (event: ChannelConnectedLine, channel: Channel) => void
): void;
/**
* Error emitted when WebSocket reconnection attempts exceeded MaxRetries.
*/
// tslint:disable-next-line:unified-signatures
addListener(type: WebSocketMaxRetriesEventType, listener: (err: Error) => void): void;
/**
* Error emitted when the WebSocket is reconnecting.
*/
// tslint:disable-next-line:unified-signatures
addListener(type: WebSocketReconnectingEventType, listener: (err: Error) => void): void;
/**
* Event emitted when the WebSocket is connected.
*/
// tslint:disable-next-line:unified-signatures
addListener(type: WebSocketConnectedEventType, listener: () => void): void;
/**
* Event emitted when a WebSocket pong is received.
*/
// tslint:disable-next-line:unified-signatures
addListener(type: PongEventType, listener: () => void): void;
/**
* Error event sent when connection to API fails.
*/
// tslint:disable-next-line:unified-signatures
addListener(type: APILoadErrorEventType, listener: (err: Error) => void): void;
/**
* Base type for errors and events.
*/
addListener(
event: MessageEventType,
callback: (event: Message, instances: Message) => void
): void;
/**
* Error event sent when required params are missing.
*/
addListener(
event: MissingParamsEventType,
callback: (event: MissingParams, instances: MissingParams) => void
): void;
/**
* Base type for asynchronous events from Asterisk.
*/
addListener(event: EventEventType, callback: (event: Event, instances: Event) => void): void;
/**
* Detailed information about a contact on an endpoint.
*/
addListener(
event: ContactInfoEventType,
callback: (event: ContactInfo, instances: ContactInfo) => void
): void;
/**
* Detailed information about a remote peer that communicates with Asterisk.
*/
addListener(event: PeerEventType, callback: (event: Peer, instances: Peer) => void): void;
/**
* Notification that a device state has changed.
*/
addListener(
event: DeviceStateChangedEventType,
callback: (event: DeviceStateChanged, devicestate: DeviceState) => void
): void;
/**
* Event showing the start of a media playback operation.
*/
addListener(
event: PlaybackStartedEventType,
callback: (event: PlaybackStarted, playback: Playback) => void
): void;
/**
* Event showing the continuation of a media playback operation from one media URI to the next in the list.
*/
addListener(
event: PlaybackContinuingEventType,
callback: (event: PlaybackContinuing, playback: Playback) => void
): void;
/**
* Event showing the completion of a media playback operation.
*/
addListener(
event: PlaybackFinishedEventType,
callback: (event: PlaybackFinished, playback: Playback) => void
): void;
/**
* Event showing the start of a recording operation.
*/
addListener(
event: RecordingStartedEventType,
callback: (event: RecordingStarted, liverecording: LiveRecording) => void
): void;
/**
* Event showing the completion of a recording operation.
*/
addListener(
event: RecordingFinishedEventType,
callback: (event: RecordingFinished, liverecording: LiveRecording) => void
): void;
/**
* Event showing failure of a recording operation.
*/
addListener(
event: RecordingFailedEventType,
callback: (event: RecordingFailed, liverecording: LiveRecording) => void
): void;
/**
* Notification that trying to move a channel to another Stasis application failed.
*/
addListener(
event: ApplicationMoveFailedEventType,
callback: (event: ApplicationMoveFailed, channel: Channel) => void
): void;
/**
* Notification that another WebSocket has taken over for an application. An application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe
* to the same application, the newer WebSocket wins, and the older one receives this event.
*/
addListener(event: ApplicationReplacedEventType, callback: (event: Event) => void): void;
/**
* Notification that a bridge has been created.
*/
addListener(
event: BridgeCreatedEventType,
callback: (event: BridgeCreated, bridge: Bridge) => void
): void;
/**
* Notification that a bridge has been destroyed.
*/
addListener(
event: BridgeDestroyedEventType,
callback: (event: BridgeDestroyed, bridge: Bridge) => void
): void;
/**
* Notification that one bridge has merged into another.
*/
addListener(
event: BridgeMergedEventType,
callback: (event: BridgeMerged, bridge: Bridge) => void
): void;
/**
* Notification that the source of video in a bridge has changed.
*/
addListener(
event: BridgeVideoSourceChangedEventType,
callback: (event: BridgeVideoSourceChanged, bridge: Bridge) => void
): void;
/**
* Notification that a blind transfer has occurred.
*/
addListener(
event: BridgeBlindTransferEventType,
callback: (event: BridgeBlindTransfer, instances: BridgeBlindTransfer) => void
): void;
/**
* Notification that an attended transfer has occurred.
*/
addListener(
event: BridgeAttendedTransferEventType,
callback: (event: BridgeAttendedTransfer, instances: BridgeAttendedTransfer) => void
): void;
/**
* Notification that a channel has been created.
*/
addListener(
event: ChannelCreatedEventType,
callback: (event: ChannelCreated, channel: Channel) => void
): void;
/**
* Notification that a channel has been destroyed.
*/
addListener(
event: ChannelDestroyedEventType,
callback: (event: ChannelDestroyed, channel: Channel) => void
): void;
/**
* Notification that a channel has entered a bridge.
*/
addListener(
event: ChannelEnteredBridgeEventType,
callback: (event: ChannelEnteredBridge, instances: ChannelEnteredBridge) => void
): void;
/**
* Notification that a channel has left a bridge.
*/
addListener(
event: ChannelLeftBridgeEventType,
callback: (event: ChannelLeftBridge, instances: ChannelLeftBridge) => void
): void;
/**
* Notification of a channels state change.
*/
addListener(
event: ChannelStateChangeEventType,
callbac