class Protocol::HTTP2::Stream

def close!(error_code = nil)

@parameter error_code [Integer | Nil] The error code if the stream was closed due to a stream reset.
Transition the stream into the closed state.
def close!(error_code = nil)
	@state = :closed
	@connection.delete(@id)
	
	# `NO_ERROR` represents an orderly stream closure, so it is passed to `closed` as `nil` rather than converted to an exception.
	if error_code == REFUSED_STREAM
		error = ::Protocol::HTTP::RefusedError.new("Stream refused.")
	elsif error_code && error_code != NO_ERROR
		error = StreamError.for(error_code)
	end
	
	self.closed(error)
	
	return self
end