close method
void
close()
Destroy the current peer, closes all the transports, producers and consumers
Implementation
void close() {
_device = null;
navigator.mediaDevices.ondevicechange = null;
_pendingConsumerTasks.clear();
_pendingProducerTasks.clear();
_pendingTransportTasks.clear();
_pendingFetchingStream.clear();
_waitingToProduce.clear();
_waitingToConsume.clear();
for (final stream in _activeStreams.values) {
for (final track in stream.getTracks()) {
track.stop();
}
}
joined = false;
deviceHandler.destroy();
if (_sendTransport != null) {
_sendTransport?.close();
}
if (_recvTransport != null) {
_recvTransport?.close();
}
_sendTransport = null;
_recvTransport = null;
_permissions.reset();
emit('permissions-updated', {
'permissions': permissions,
'role': role ?? '',
});
}