module Plum::ConnectionUtils

Public Instance Methods

goaway(error_type = :no_error, message = "") click to toggle source

Sends GOAWAY frame to the peer and closes the connection. @param error_type [Symbol] The error type to be contained in the GOAWAY frame.

# File lib/plum/connection_utils.rb, line 21
def goaway(error_type = :no_error, message = "")
  last_id = @max_stream_ids.max
  send_immediately Frame.goaway(last_id, error_type, message)
end
ping(data = "plum\x00\x00\x00\x00") click to toggle source

Sends a PING frame to the peer. @param data [String] Must be 8 octets. @raise [ArgumentError] If the data is not 8 octets.

# File lib/plum/connection_utils.rb, line 15
def ping(data = "plum\x00\x00\x00\x00")
  send_immediately Frame.ping(data)
end
push_enabled?() click to toggle source

Returns whether peer enables server push or not

# File lib/plum/connection_utils.rb, line 27
def push_enabled?
  @remote_settings[:enable_push] == 1
end
settings(**kwargs) click to toggle source

Sends local settings to the peer. @param kwargs [Hash<Symbol, Integer>]

# File lib/plum/connection_utils.rb, line 7
def settings(**kwargs)
  send_immediately Frame.settings(**kwargs)
  update_local_settings(kwargs)
end

Private Instance Methods

update_local_settings(new_settings) click to toggle source
# File lib/plum/connection_utils.rb, line 32
def update_local_settings(new_settings)
  old_settings = @local_settings.dup
  @local_settings.merge!(new_settings)

  @hpack_decoder.limit = @local_settings[:header_table_size]
  update_recv_initial_window_size(@local_settings[:initial_window_size] - old_settings[:initial_window_size])
end