endCall function

Future<void> endCall({
  1. required SessionController sessionController,
})

Function to dispose the RTC and RTM engine.

Implementation

Future<void> endCall({required SessionController sessionController}) async {
  if (sessionController.value.connectionData!.screenSharingEnabled &&
      sessionController.value.isScreenShared) {
    await sessionController.value.engine?.stopScreenCapture();
  }
  await sessionController.value.engine?.stopPreview();
  await sessionController.value.engine?.leaveChannel();
  if (sessionController.value.connectionData!.rtmEnabled) {
    await sessionController.value.agoraRtmChannel?.leave();
    await sessionController.value.agoraRtmClient?.logout();
  }
  await sessionController.value.engine?.release();
}