Class: Arf::Wire::GoAwayFrame

Inherits:
BaseFrame show all
Defined in:
lib/arf/wire/frames/go_away_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

#additional_dataObject

Returns the value of attribute additional_data.



8
9
10
# File 'lib/arf/wire/frames/go_away_frame.rb', line 8

def additional_data
  @additional_data
end

#error_codeObject

Returns the value of attribute error_code.



8
9
10
# File 'lib/arf/wire/frames/go_away_frame.rb', line 8

def error_code
  @error_code
end

#last_stream_idObject

Returns the value of attribute last_stream_id.



8
9
10
# File 'lib/arf/wire/frames/go_away_frame.rb', line 8

def last_stream_id
  @last_stream_id
end

Instance Method Details

#encode_payloadObject



20
21
22
23
24
25
26
# File 'lib/arf/wire/frames/go_away_frame.rb', line 20

def encode_payload
  buf = IO::Buffer.new
    .write_raw(encode_uint32(last_stream_id))
    .write_raw(encode_uint32(error_code))
  buf.write_raw(additional_data) if additional_data
  buf.string
end

#from_frame(fr) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/arf/wire/frames/go_away_frame.rb', line 10

def from_frame(fr)
  if fr.length < 8
    raise InvalidFrameLengthError, "Invalid length for frame GOAWAY: at" \
                                   "least 8 bytes are required"
  end
  @last_stream_id = decode_uint32(fr.payload)
  @error_code = decode_uint32(fr.payload)
  @additional_data = fr.payload.read
end