Class: Nervion::Stream
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Nervion::Stream
- Defined in:
- lib/nervion/stream.rb
Instance Attribute Summary collapse
-
#http_error ⇒ Object
readonly
Returns the value of attribute http_error.
Instance Method Summary collapse
- #close ⇒ Object
- #close_requested? ⇒ Boolean
- #connection_completed ⇒ Object
- #http_error_occurred? ⇒ Boolean
-
#initialize(*args) ⇒ Stream
constructor
A new instance of Stream.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #retry ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(*args) ⇒ Stream
Returns a new instance of Stream.
10 11 12 13 |
# File 'lib/nervion/stream.rb', line 10 def initialize(*args) @request = args[0] @handler = args[1] end |
Instance Attribute Details
#http_error ⇒ Object (readonly)
Returns the value of attribute http_error.
8 9 10 |
# File 'lib/nervion/stream.rb', line 8 def http_error @http_error end |
Instance Method Details
#close ⇒ Object
47 48 49 50 |
# File 'lib/nervion/stream.rb', line 47 def close @close_stream = true close_connection end |
#close_requested? ⇒ Boolean
43 44 45 |
# File 'lib/nervion/stream.rb', line 43 def close_requested? @close_stream ||= false end |
#connection_completed ⇒ Object
19 20 21 22 |
# File 'lib/nervion/stream.rb', line 19 def connection_completed start_tls send_data @request end |
#http_error_occurred? ⇒ Boolean
39 40 41 |
# File 'lib/nervion/stream.rb', line 39 def http_error_occurred? not http_error.nil? end |
#post_init ⇒ Object
15 16 17 |
# File 'lib/nervion/stream.rb', line 15 def post_init @scheduler = ReconnectionScheduler.new end |
#receive_data(data) ⇒ Object
24 25 26 27 28 |
# File 'lib/nervion/stream.rb', line 24 def receive_data(data) @handler << data rescue HttpError => error @http_error = error end |
#retry ⇒ Object
30 31 32 33 |
# File 'lib/nervion/stream.rb', line 30 def retry @http_error = nil reconnect @request.host, @request.port end |
#unbind ⇒ Object
35 36 37 |
# File 'lib/nervion/stream.rb', line 35 def unbind handle_closed_stream unless close_requested? end |