in lib/src/connection.dart [366:398]
void _finishing({bool active = true, String? message}) {
// If this connection is already dead, we return.
if (_state.isTerminated) return;
// If this connection is already finishing, we make sure to store the
// passive bit, since this information is used by [StreamHandler].
//
// Vice versa should not matter: If we started passively finishing, an
// active finish should be a NOP.
if (_state.isFinishing) {
if (!active) _state.finishingState |= ConnectionState.FinishingPassive;
return;
}
assert(_state.isInitialized || _state.isOperational);
// If we are actively finishing this connection, we'll send a
// GoawayFrame otherwise we'll just propagate the message.
if (active) {
_state.state = ConnectionState.Finishing;
_state.finishingState |= ConnectionState.FinishingActive;
_outgoingQueue.enqueueMessage(GoawayMessage(
_streams.highestPeerInitiatedStream,
ErrorCode.NO_ERROR,
message != null ? utf8.encode(message) : []));
} else {
_state.state = ConnectionState.Finishing;
_state.finishingState |= ConnectionState.FinishingPassive;
}
_streams.startClosing();
}