closeCurrentSession method

Future<void> closeCurrentSession()
inherited

Implementation

Future<void> closeCurrentSession() async {
  log("closeCurrentSession", _TAG);
  setState(RTCSessionState.RTC_SESSION_CLOSED);
  if (localStream != null) {
    log("[closeCurrentSession] dispose localStream", _TAG);
    try {
      localStream?.getTracks().forEach((track) async {
        await track.stop();
      });
      await localStream?.dispose();
    } catch (error) {
      log('closeCurrentSession ERROR: $error');
    }

    localStream = null;
  }

  statsReportsStreamController.close();

  notifySessionClosed();
}