dispose method
Future<void>
dispose(
)
override
Implementation
@override
Future<void> dispose() async {
try {
if (_mParticipant == null) return;
if (_roomId != null) {
_socketEmiter.leaveRoom(_roomId!);
}
_roomId = null;
_participantId = null;
_queuePublisherCandidates.clear();
_queueRemoteSubCandidates.clear();
_flagPublisherCanAddCandidate = false;
_nativeService.endCallKit();
_stats.dispose();
_audioStats.dispose();
for (final subscriber in _subscribers.values) {
await subscriber.dispose();
}
_subscribers.clear();
await stopScreenSharing(stayInRoom: false);
for (final MediaStreamTrack track in _localStream?.getTracks() ?? []) {
track.stop();
}
await _localStream?.dispose();
await _mParticipant?.dispose();
_mParticipant = null;
_localStream = null;
_frameCryptor.dispose();
_notify(CallbackEvents.meetingEnded);
// Clear for next time
disableVirtualBackground(reset: true);
} catch (error) {
WaterbusLogger().bug(error.toString());
}
}