Class: HTTP2Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/polyphony/http/client/http2.rb

Overview

HTTP 2 adapter

Defined Under Namespace

Classes: StreamAdapter

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ HTTP2Adapter

Returns a new instance of HTTP2Adapter.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/polyphony/http/client/http2.rb', line 11

def initialize(socket)
  @socket = socket
  @client = HTTP2::Client.new
  @client.on(:frame) { |bytes| socket << bytes }
  # @client.on(:frame_received) do |frame|
  #   puts "Received frame: #{frame.inspect}"
  # end
  # @client.on(:frame_sent) do |frame|
  #   puts "Sent frame: #{frame.inspect}"
  # end

  @reader = spin do
    while (data = socket.readpartial(8192))
      @client << data
      snooze
    end
  end
end

Instance Method Details

#allocate_streamObject



34
35
36
# File 'lib/polyphony/http/client/http2.rb', line 34

def allocate_stream
  @client.new_stream
end

#allocate_stream_adapterObject



30
31
32
# File 'lib/polyphony/http/client/http2.rb', line 30

def allocate_stream_adapter
  StreamAdapter.new(self)
end

#protocolObject



38
39
40
# File 'lib/polyphony/http/client/http2.rb', line 38

def protocol
  :http2
end