Module: Async::HTTY::Protocol::HTTY

Defined in:
lib/async/htty/protocol/htty.rb,
lib/async/htty/protocol/htty/server.rb

Defined Under Namespace

Classes: Server

Class Method Summary collapse

Class Method Details

.client(stream, settings: ::Async::HTTP::Protocol::HTTP2::CLIENT_SETTINGS) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/async/htty/protocol/htty.rb', line 15

def self.client(stream, settings: ::Async::HTTP::Protocol::HTTP2::CLIENT_SETTINGS)
	mode = stream.read_bootstrap
	
	unless mode == ::Protocol::HTTY::Stream::RAW_MODE
		raise ::Protocol::HTTY::ProtocolError, "Expected HTTY bootstrap mode #{::Protocol::HTTY::Stream::RAW_MODE.inspect}, got #{mode.inspect}"
	end
	
	client = ::Async::HTTP::Protocol::HTTP2::Client.new(stream)
	client.send_connection_preface(settings)
	client.start_connection
	
	return client
end

.namesObject



39
40
41
# File 'lib/async/htty/protocol/htty.rb', line 39

def self.names
	["htty"]
end

.server(stream, settings: ::Async::HTTP::Protocol::HTTP2::SERVER_SETTINGS) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/async/htty/protocol/htty.rb', line 29

def self.server(stream, settings: ::Async::HTTP::Protocol::HTTP2::SERVER_SETTINGS)
	stream.write_bootstrap
	
	server = Server.new(stream)
	server.read_connection_preface(settings)
	server.start_connection
	
	return server
end