Class: Arf::Wire::ConfigurationFrame

Inherits:
BaseFrame
  • Object
show all
Defined in:
lib/arf/wire/frames/configuration_frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseFrame

#decode_flags, #decode_uint16, #decode_uint32, define_flag, #encode_flags, #encode_uint16, #encode_uint32, flags, #flags, frame_by_kind, frame_kind, #frame_kind, #initialize, #inspect_flags, register_frame, #to_frame, #value_size, value_size, wants_stream_id!, #wants_stream_id?, wants_stream_id?

Constructor Details

This class inherits a constructor from Arf::Wire::BaseFrame

Instance Attribute Details

#max_concurrent_streamsObject

Returns the value of attribute max_concurrent_streams.



10
11
12
# File 'lib/arf/wire/frames/configuration_frame.rb', line 10

def max_concurrent_streams
  @max_concurrent_streams
end

Instance Method Details

#encode_payloadObject



26
27
28
29
30
# File 'lib/arf/wire/frames/configuration_frame.rb', line 26

def encode_payload
  return unless @max_concurrent_streams

  encode_uint32(@max_concurrent_streams)
end

#from_frame(frame) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/arf/wire/frames/configuration_frame.rb', line 12

def from_frame(frame)
  if !frame.empty? && frame.length != 4
    raise InvalidFrameLengthError, "invalid length for frame CONFIGURATION " \
                                   "expected 0 or 4 bytes, got #{frame.length}"
  end

  @max_concurrent_streams = decode_uint32(frame.payload) unless frame.empty?

  return unless @max_concurrent_streams && @max_concurrent_streams != 0 && !ack?

  raise InvalidFrameError, "received non-ack CONFIGURATION with " \
                           "non-zero max_concurrent_streams"
end