Class: Faye::Engine::Connection
- Inherits:
-
Object
- Object
- Faye::Engine::Connection
- Includes:
- Deferrable, Timeouts
- Defined in:
- lib/faye/engines/connection.rb
Instance Attribute Summary collapse
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
- #connect(options, &block) ⇒ Object
- #deliver(message) ⇒ Object
- #flush ⇒ Object
-
#initialize(engine, id, options = {}) ⇒ Connection
constructor
A new instance of Connection.
Methods included from Timeouts
#add_timeout, #remove_all_timeouts, #remove_timeout
Methods included from Deferrable
Constructor Details
#initialize(engine, id, options = {}) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 |
# File 'lib/faye/engines/connection.rb', line 10 def initialize(engine, id, = {}) @engine = engine @id = id @options = @inbox = Set.new end |
Instance Attribute Details
#socket ⇒ Object
Returns the value of attribute socket.
8 9 10 |
# File 'lib/faye/engines/connection.rb', line 8 def socket @socket end |
Instance Method Details
#connect(options, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/faye/engines/connection.rb', line 24 def connect(, &block) = || {} timeout = ['timeout'] ? ['timeout'] / 1000.0 : @engine.timeout set_deferred_status(:unknown) callback(&block) begin_delivery_timeout begin_connection_timeout(timeout) end |
#deliver(message) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/faye/engines/connection.rb', line 17 def deliver() .delete('clientId') return @socket.send() if @socket return unless @inbox.add?() begin_delivery_timeout end |
#flush ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/faye/engines/connection.rb', line 35 def flush remove_timeout(:connection) remove_timeout(:delivery) set_deferred_status(:succeeded, @inbox.entries) @inbox = [] @engine.close_connection(@id) unless @socket end |