Class: Quicsilver::Transport::InboundStream

Inherits:
Object
  • Object
show all
Defined in:
lib/quicsilver/transport/inbound_stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_id, is_unidirectional: nil) ⇒ InboundStream

Returns a new instance of InboundStream.



9
10
11
12
13
14
# File 'lib/quicsilver/transport/inbound_stream.rb', line 9

def initialize(stream_id, is_unidirectional: nil)
  @stream_id = stream_id
  @is_unidirectional = is_unidirectional.nil? ? !bidirectional? : is_unidirectional
  @buffer = StringIO.new.tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
  @stream_handle = nil
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



6
7
8
# File 'lib/quicsilver/transport/inbound_stream.rb', line 6

def buffer
  @buffer
end

#is_unidirectionalObject (readonly)

Returns the value of attribute is_unidirectional.



6
7
8
# File 'lib/quicsilver/transport/inbound_stream.rb', line 6

def is_unidirectional
  @is_unidirectional
end

#stream_handleObject

Returns the value of attribute stream_handle.



7
8
9
# File 'lib/quicsilver/transport/inbound_stream.rb', line 7

def stream_handle
  @stream_handle
end

#stream_idObject (readonly)

Returns the value of attribute stream_id.



6
7
8
# File 'lib/quicsilver/transport/inbound_stream.rb', line 6

def stream_id
  @stream_id
end

Instance Method Details

#append_data(data) ⇒ Object



24
25
26
# File 'lib/quicsilver/transport/inbound_stream.rb', line 24

def append_data(data)
  @buffer.write(data)
end

#bidirectional?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/quicsilver/transport/inbound_stream.rb', line 16

def bidirectional?
  (stream_id & 0x02) == 0
end

#dataObject



28
29
30
# File 'lib/quicsilver/transport/inbound_stream.rb', line 28

def data
  @buffer.string
end

#writable?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/quicsilver/transport/inbound_stream.rb', line 20

def writable?
  !stream_handle.nil?
end