Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
:warning: **Important**: If you are upgrading to version 2.3.0 or later and have firewall rules or network configuration that blocks any unknown traffic by default, you need to update your configuration to allow connections to the new DNS names and IP addresses. Please refer to this [changelog](#230-january-23-2023) for more details.

*Next Release*
====================

New Features
------------

- Added `Call` [status](https://github.com/twilio/twilio-voice.js/commit/887ce625730b1cd96d08f453177e2a8db70014a9) events with [Call.CallStatus](https://github.com/twilio/twilio-voice.js/commit/9164ae8bd4e51ca258ed2573d69a1a3051e8a803) providing granular insight into the current call. [@cybex-dev](https://github.com/cybex-dev)


2.13.0 (May 6, 2025)
====================

Expand Down
31 changes: 31 additions & 0 deletions lib/twilio/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ class Call extends EventEmitter {
this._log.debug('#disconnect');
this.emit('disconnect', this);
}
this.emit('status', Call.CallStatus.Closed);
};

this._pstream = config.pstream;
Expand Down Expand Up @@ -644,6 +645,7 @@ class Call extends EventEmitter {
};

this._status = Call.State.Connecting;
this.emit('status', Call.CallStatus.Connecting);

const connect = () => {
if (this._status !== Call.State.Connecting) {
Expand Down Expand Up @@ -780,6 +782,7 @@ class Call extends EventEmitter {
if (this._onIgnore) {
this._onIgnore();
}
this.emit('status', Call.CallStatus.Closed);
}

/**
Expand Down Expand Up @@ -855,6 +858,8 @@ class Call extends EventEmitter {
this._status = Call.State.Closed;
this._log.debug('#reject');
this.emit('reject');
this.emit('status', Call.CallStatus.Rejected);
this.emit('status', Call.CallStatus.Closed);
}

/**
Expand Down Expand Up @@ -1158,6 +1163,7 @@ class Call extends EventEmitter {
this._log.debug('#accept');
this.emit('accept', this);
}
this.emit('status', Call.CallStatus.Connected);
}
}
}
Expand Down Expand Up @@ -1197,6 +1203,7 @@ class Call extends EventEmitter {
this._setCallSid(payload);
this._isAnswered = true;
this._maybeTransitionToOpen();
this.emit('status', Call.CallStatus.Answer);
}

/**
Expand All @@ -1216,6 +1223,7 @@ class Call extends EventEmitter {
this._log.debug('#cancel');
this.emit('cancel');
this._pstream.removeListener('cancel', this._onCancel);
this.emit('status', Call.CallStatus.Closed);
}
}

Expand All @@ -1232,6 +1240,7 @@ class Call extends EventEmitter {
this._signalingReconnectToken,
);
}
this.emit('status', Call.CallStatus.Connected);
}

/**
Expand Down Expand Up @@ -1349,6 +1358,7 @@ class Call extends EventEmitter {

this._log.debug('#reconnecting');
this.emit('reconnecting', mediaReconnectionError);
this.emit('status', Call.CallStatus.Reconnecting);
}
}

Expand All @@ -1369,6 +1379,7 @@ class Call extends EventEmitter {
this._log.debug('#reconnected');
this.emit('reconnected');
this._status = Call.State.Open;
this.emit('status', Call.CallStatus.Reconnected);
}
}

Expand Down Expand Up @@ -1437,6 +1448,7 @@ class Call extends EventEmitter {
this._publisher.info('connection', 'outgoing-ringing', { hasEarlyMedia }, this);
this._log.debug('#ringing');
this.emit('ringing', hasEarlyMedia);
this.emit('status', Call.CallStatus.Ringing);
}

/**
Expand Down Expand Up @@ -1517,6 +1529,7 @@ class Call extends EventEmitter {
this._log.debug('#reconnected');
this.emit('reconnected');
this._status = Call.State.Open;
this.emit('status', Call.CallStatus.Reconnected);
}
}

Expand All @@ -1533,9 +1546,11 @@ class Call extends EventEmitter {
this._signalingStatus = Call.State.Reconnecting;
this._log.debug('#reconnecting');
this.emit('reconnecting', new SignalingErrors.ConnectionDisconnected());
this.emit('status', Call.CallStatus.Reconnecting);
} else {
this._status = Call.State.Closed;
this._signalingStatus = Call.State.Closed;
this.emit('status', Call.CallStatus.Closed);
}
}

Expand Down Expand Up @@ -1774,6 +1789,22 @@ namespace Call {
Ringing = 'ringing',
}

/**
* Possible statuses of the {@link Call}.
* These statuses are used to indicate the current state of the call, to provide integration with 3rd party plugins or
* to provide a way to track the call state in a UI.
*/
export enum CallStatus {
Closed = 'closed',
Connecting = 'connecting',
Connected = 'connected',
Reconnecting = 'reconnecting',
Reconnected = 'reconnected',
Ringing = 'ringing',
Rejected = 'rejected',
Answer = 'answer',
}

/**
* Different issues that may have been experienced during a call, that can be
* reported to Twilio Insights via {@link Call}.postFeedback().
Expand Down
1 change: 1 addition & 0 deletions lib/twilio/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ class Device extends EventEmitter {
parameters: call.parameters,
}));
this.emit(Device.EventName.Incoming, call);
call.emit('status', Call.State.Ringing);
});
}

Expand Down