class Protocol::HTTP2::Server

connection preface handling, and settings negotiation.
Manages server-side protocol semantics including stream ID allocation,
Represents an HTTP/2 server connection.

def accept_push_promise_stream(stream_id, &block)

@raises [ProtocolError] Always, as servers cannot accept push promises.
@parameter stream_id [Integer] The stream ID (unused).
Servers cannot accept push promise streams from clients.
def accept_push_promise_stream(stream_id, &block)
	raise ProtocolError, "Cannot accept push promises on server!"
end

def enable_push?

@returns [Boolean] True if push promises are enabled.
Check if server push is enabled by the client.
def enable_push?
	@remote_settings.enable_push?
end

def initialize(framer)

@parameter framer [Framer] The frame handler for reading/writing HTTP/2 frames.
Initialize a new HTTP/2 server connection.
def initialize(framer)
	super(framer, 2)
end

def local_stream_id?(id)

@returns [Boolean] True if the stream ID is locally-initiated.
@parameter id [Integer] The stream ID to check.
Server streams have even numbered IDs.
Check if the given stream ID represents a locally-initiated stream.
def local_stream_id?(id)
	id.even?
end

def read_connection_preface(settings = [])

@raises [ProtocolError] If called when not in the new state or preface is invalid.
@parameter settings [Array] Optional settings to send during preface exchange.
This must be called once when the connection is first established.
Read the HTTP/2 connection preface from the client and send initial settings.
def read_connection_preface(settings = [])
	if @state == :new
		@framer.read_connection_preface
		
		send_settings(settings)
		
		read_frame do |frame|
			unless frame.is_a? SettingsFrame
				raise ProtocolError, "First frame must be #{SettingsFrame}, but got #{frame.class}"
			end
		end
	else
		raise ProtocolError, "Cannot read connection preface in state #{@state}"
	end
end

def remote_stream_id?(id)

@returns [Boolean] True if the stream ID is remotely-initiated.
@parameter id [Integer] The stream ID to check.
Client streams have odd numbered IDs.
Check if the given stream ID represents a remotely-initiated stream.
def remote_stream_id?(id)
	id.odd?
end

def valid_remote_stream_id?(stream_id)

@returns [Boolean] True if the stream ID is valid for remote initiation.
@parameter stream_id [Integer] The stream ID to validate.
Client-initiated streams must have odd numbered IDs.
Check if the given stream ID is valid for remote initiation.
def valid_remote_stream_id?(stream_id)
	stream_id.odd?
end