close method
Closes the channel. Idempotent.
Implementation
@override
Future<void> close() async {
if (_closed) return;
_txDroppedBytes += _pendingWriteBytes;
_pendingWriteBytes = 0;
_closed = true;
final alreadyDisconnected = _current == ConnectionState.disconnected;
_current = ConnectionState.disconnected;
// Mirror every real transport: emit the terminal state before closing.
if (!_state.isClosed) {
if (!alreadyDisconnected) _state.add(ConnectionState.disconnected);
await _state.close();
}
if (!_incoming.isClosed) await _incoming.close();
}