Class: Gazouillis::Stream
- Inherits:
-
Object
- Object
- Gazouillis::Stream
- Includes:
- Celluloid::IO
- Defined in:
- lib/gazouillis/stream.rb
Overview
This class concern is to handle stream connections.
Instance Attribute Summary collapse
-
#http_parser ⇒ Object
readonly
Returns the value of attribute http_parser.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(path, opts) ⇒ Stream
constructor
A new instance of Stream.
- #on_message(message) ⇒ Object
- #open ⇒ Object
Constructor Details
#initialize(path, opts) ⇒ Stream
Returns a new instance of Stream.
9 10 11 12 13 14 15 16 |
# File 'lib/gazouillis/stream.rb', line 9 def initialize(path, opts) = .merge(opts) @request = Request.new(path, ) @stream = set_stream(TCPSocket.new [:host], [:port]) @http_parser = Http::Parser.new http_parser.on_body = http_parser.on_headers_complete = on_headers_complete end |
Instance Attribute Details
#http_parser ⇒ Object (readonly)
Returns the value of attribute http_parser.
7 8 9 |
# File 'lib/gazouillis/stream.rb', line 7 def http_parser @http_parser end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
7 8 9 |
# File 'lib/gazouillis/stream.rb', line 7 def request @request end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
7 8 9 |
# File 'lib/gazouillis/stream.rb', line 7 def stream @stream end |
Instance Method Details
#close ⇒ Object
23 24 25 |
# File 'lib/gazouillis/stream.rb', line 23 def close stream.to_io.close end |
#on_message(message) ⇒ Object
27 28 29 |
# File 'lib/gazouillis/stream.rb', line 27 def () # Hook method. To be override. end |
#open ⇒ Object
18 19 20 21 |
# File 'lib/gazouillis/stream.rb', line 18 def open stream.write request handle_connection end |