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 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.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gazouillis/stream.rb', line 8 def initialize(path, opts) @options = .merge(opts).merge(path: path) socket = TCPSocket.new "stream.twitter.com", 443 ssl = OpenSSL::SSL::SSLSocket.new(socket.to_io, OpenSSL::SSL::SSLContext.new) ssl.sync = true ssl.connect @stream = ssl @http_parser = Http::Parser.new @http_parser.on_body = @http_parser.on_headers_complete = on_headers_complete end |
Instance Method Details
#close ⇒ Object
29 30 31 |
# File 'lib/gazouillis/stream.rb', line 29 def close @stream.to_io.close end |
#on_message(message) ⇒ Object
33 34 35 |
# File 'lib/gazouillis/stream.rb', line 33 def () # Hook method. To be override. end |
#open ⇒ Object
24 25 26 27 |
# File 'lib/gazouillis/stream.rb', line 24 def open @stream.write request handle_connection end |