teardown method
断开媒体、停止心跳和续期;通话已结束(或 isFinal)的句柄结束:快照不再变化。
Implementation
Future<void> teardown(bool isFinal) async {
final hadSession = _session != null;
_unbindSession();
_heartbeat?.call();
_heartbeat = null;
_renewTimer?.cancel();
_renewTimer = null;
_ringTimer?.cancel();
_ringTimer = null;
if (hadSession) {
_holding = false;
_set(media: 'disconnected', local: const CallLocalMedia(), remote: const []);
_module.reportHolder(callId, false);
}
if ((isFinal || snapshot.call.status == 'ended') && !_ended) {
_set(ringing: false);
_ended = true;
_holding = false;
_releaseHold?.call();
_releaseHold = null;
_module.noteCurrent(callId, false);
_module.forget(this);
unawaited(_tracks.close());
unawaited(_data.close());
}
}