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
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sockjs/session.rb', line 42 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
37 38 39 |
# File 'lib/sockjs/session.rb', line 37 def closing(status, ) transport.closing_frame(response, status, ) end |
#disconnect ⇒ Object
Close the response not the session
17 18 19 20 21 22 23 24 25 |
# File 'lib/sockjs/session.rb', line 17 def disconnect #WEBSOCKET shouldn't have limit of data - faye will send closing frame #after 1GB if @transport.kind_of?(SockJS::Transports::WebSocket) @total_sent_length = 0 return end @response.finish if @response.respond_to?(:finish) end |
#heartbeat ⇒ Object
27 28 29 |
# File 'lib/sockjs/session.rb', line 27 def heartbeat transport.heartbeat_frame(response) end |
#messages(items) ⇒ Object
31 32 33 34 35 |
# File 'lib/sockjs/session.rb', line 31 def (items) unless items.empty? @total_sent_length += transport.(response, items) end end |