endCall method

Future<void> endCall()

End Call Session

Implementation

Future<void> endCall() async {
  _setState(CallState.ending);
  _cancelRingTimeoutTimer();
  _cancelGracePeriodTimer();
  _stopSessionTimer();

  try {
    if (_callType == CallType.video) {
      await _engine?.stopPreview();
    }
    await _engine?.leaveChannel();
    await _engine?.release();
    _engine = null;
  } catch (e) {
    debugPrint('Error during endCall release: $e');
  }

  _setState(CallState.ended);
  onCallEnded?.call(_currentSession);
}