aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum/client/connection.rb
blob: 8721fb516ab51d71bd75e5919f14344598c080c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# -*- frozen-string-literal: true -*-
using Plum::BinaryString
module Plum
  class ClientConnection < Connection
    def initialize(writer, local_settings = {})
      super(writer, local_settings)

      writer.call(CLIENT_CONNECTION_PREFACE)
      settings(local_settings)
      @state = :waiting_settings
    end

    # Create a new stream for HTTP request.
    # @param args [Hash] the argument for Stream.new
    def open_stream
      next_id = @max_stream_id + (@max_stream_id.even? ? 1 : 2)
      stream(next_id)
    end
  end
end