Class: SockJS::Session::Consumer
- Inherits:
-
Object
- Object
- SockJS::Session::Consumer
- Defined in:
- lib/sockjs/session.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#total_sent_length ⇒ Object
readonly
Returns the value of attribute total_sent_length.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Instance Method Summary collapse
-
#check_alive ⇒ Object
XXX Still not sure what this is FOR.
- #closing(status, message) ⇒ Object
-
#disconnect ⇒ Object
Close the response not the session.
- #heartbeat ⇒ Object
-
#initialize(response, transport) ⇒ Consumer
constructor
A new instance of Consumer.
- #messages(items) ⇒ Object
Constructor Details
#initialize(response, transport) ⇒ Consumer
Returns a new instance of Consumer.
9 10 11 12 13 |
# File 'lib/sockjs/session.rb', line 9 def initialize(response, transport) @response = response @transport = transport @total_sent_length = 0 end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
14 15 16 |
# File 'lib/sockjs/session.rb', line 14 def response @response end |
#total_sent_length ⇒ Object (readonly)
Returns the value of attribute total_sent_length.
14 15 16 |
# File 'lib/sockjs/session.rb', line 14 def total_sent_length @total_sent_length end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
14 15 16 |
# File 'lib/sockjs/session.rb', line 14 def transport @transport end |
Instance Method Details
#check_alive ⇒ Object
XXX Still not sure what this is FOR
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sockjs/session.rb', line 36 def check_alive if !@response.body.closed? if @response.due_for_alive_check SockJS.debug "Checking if still alive" @response.write(@transport.empty_string) else puts "~ [TODO] Not checking if still alive, why?" puts "Status: #{@status} (response.body.closed: #{@response.body.closed?})\nSession class: #{self.class}\nTransport class: #{@transport.class}\nResponse: #{@response.to_s}\n\n" end end end |
#closing(status, message) ⇒ Object
31 32 33 |
# File 'lib/sockjs/session.rb', line 31 def closing(status, ) transport.closing_frame(response, status, ) end |
#disconnect ⇒ Object
Close the response not the session
17 18 19 |
# File 'lib/sockjs/session.rb', line 17 def disconnect @response.finish end |
#heartbeat ⇒ Object
21 22 23 |
# File 'lib/sockjs/session.rb', line 21 def heartbeat transport.heartbeat_frame(response) end |
#messages(items) ⇒ Object
25 26 27 28 29 |
# File 'lib/sockjs/session.rb', line 25 def (items) unless items.empty? @total_sent_length += transport.(response, items) end end |