module Async::HTTP::Protocol::HTTP2::Connection

def close(error = nil)

def close(error = nil)
	@reader = nil
	
	super
end

def connected?

Can we use this connection to make requests?
def connected?
	@stream.connected?
end

def http1?

def http1?
	false
end

def http2?

def http2?
	true
end

def initialize(*)

def initialize(*)
	super
	
	@count = 0
	@reader = nil
	
	# Writing multiple frames at the same time can cause odd problems if frames are only partially written. So we use a semaphore to ensure frames are written in their entirety.
	@write_frame_guard = Async::Semaphore.new(1)
end

def multiplex

def multiplex
	self.maximum_concurrent_streams
end

def peer

def peer
	@stream.io
end

def read_in_background(task: Task.current)

def read_in_background(task: Task.current)
	task.async do |nested_task|
		nested_task.annotate("#{version} reading data for #{self.class}")
		
		begin
			while !self.closed?
				self.consume_window
				self.read_frame
			end
		rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled
			# Ignore.
		ensure
			close($!)
		end
	end
end

def reusable?

def reusable?
	!(self.closed? || @stream.closed?)
end

def start_connection

def start_connection
	@reader ||= read_in_background
end

def version

def version
	VERSION
end

def write_frame(frame)

def write_frame(frame)
	# We don't want to write multiple frames at the same time.
	@write_frame_guard.acquire do
		super
	end
end

def write_frames(&block)

def write_frames(&block)
	@write_frame_guard.acquire do
		super
	end
end