Class: Biryani::Frame::RstStream

Inherits:
Object
  • Object
show all
Defined in:
lib/biryani/frame/rst_stream.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_id, error_code) ⇒ RstStream

Returns a new instance of RstStream.

Parameters:

  • stream_id (Integer)
  • error_code (Integer)


8
9
10
11
12
# File 'lib/biryani/frame/rst_stream.rb', line 8

def initialize(stream_id, error_code)
  @f_type = FrameType::RST_STREAM
  @stream_id = stream_id
  @error_code = error_code
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



4
5
6
# File 'lib/biryani/frame/rst_stream.rb', line 4

def error_code
  @error_code
end

#f_typeObject (readonly)

Returns the value of attribute f_type.



4
5
6
# File 'lib/biryani/frame/rst_stream.rb', line 4

def f_type
  @f_type
end

#stream_idObject (readonly)

Returns the value of attribute stream_id.



4
5
6
# File 'lib/biryani/frame/rst_stream.rb', line 4

def stream_id
  @stream_id
end

Class Method Details

.read(s, _flags, stream_id) ⇒ RstStream

Parameters:

  • s (String)
  • _flags (Integer)
  • stream_id (Integer)

Returns:



32
33
34
35
36
37
# File 'lib/biryani/frame/rst_stream.rb', line 32

def self.read(s, _flags, stream_id)
  return ConnectionError.new(ErrorCode::FRAME_SIZE_ERROR, 'RST_STREAM payload length MUST be 4') if s.bytesize != 4

  error_code = s.unpack1('N')
  RstStream.new(stream_id, error_code)
end

Instance Method Details

#lengthInteger

Returns:

  • (Integer)


15
16
17
# File 'lib/biryani/frame/rst_stream.rb', line 15

def length
  4
end

#to_binary_sString

Returns:

  • (String)


20
21
22
23
24
25
# File 'lib/biryani/frame/rst_stream.rb', line 20

def to_binary_s
  payload_length = length
  flags = 0x00

  Frame.to_binary_s_header(payload_length, @f_type, flags, @stream_id) + [@error_code].pack('N')
end