unregisterStream method

void unregisterStream(
  1. int streamId
)

Unregisters a UDXStream from this socket.

Implementation

void unregisterStream(int streamId) {
  final stream = _registeredStreams[streamId];
  if (stream != null) {
    // Notify observer of stream closure (we'll get duration and bytes from the stream)
    final duration = stream.connectedAt != null
        ? DateTime.now().difference(stream.connectedAt!)
        : Duration.zero;
    metricsObserver?.onStreamClosed(
      cids.localCid,
      streamId,
      duration,
      stream.bytesRead,
      stream.bytesWritten,
    );

    _registeredStreams.remove(streamId);
    if (stream.isInitiator) {
      _activeOutgoingStreams = (_activeOutgoingStreams - 1).clamp(0, 9999);
    }
  }
}