Class: Faye::Engine::Connection
- Inherits:
-
Object
- Object
- Faye::Engine::Connection
show all
- Includes:
- EventMachine::Deferrable, Timeouts
- Defined in:
- lib/faye/engines/connection.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Timeouts
#add_timeout, #remove_timeout
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, options = {})
@engine = engine
@id = id
@options = options
@inbox = Set.new
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
8
9
10
|
# File 'lib/faye/engines/connection.rb', line 8
def id
@id
end
|
Instance Method Details
#connect(options, &block) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/faye/engines/connection.rb', line 22
def connect(options, &block)
options = options || {}
timeout = options['timeout'] ? options['timeout'] / 1000.0 : @engine.timeout
set_deferred_status(:deferred)
callback(&block)
return if @connected
@connected = true
begin_delivery_timeout
begin_connection_timeout(timeout)
end
|
#deliver(message) ⇒ Object
17
18
19
20
|
# File 'lib/faye/engines/connection.rb', line 17
def deliver(message)
return unless @inbox.add?(message)
begin_delivery_timeout
end
|
#flush! ⇒ Object
37
38
39
40
|
# File 'lib/faye/engines/connection.rb', line 37
def flush!
release_connection!
set_deferred_status(:succeeded, @inbox.entries)
end
|