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
#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
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/faye/engines/connection.rb', line 23
def connect(options, &block)
options = options || {}
timeout = options['timeout'] ? options['timeout'] / 1000.0 : @engine.timeout
set_deferred_status(:deferred)
callback(&block)
begin_delivery_timeout
begin_connection_timeout(timeout)
end
|
#deliver(message) ⇒ Object
17
18
19
20
21
|
# File 'lib/faye/engines/connection.rb', line 17
def deliver(message)
return socket.send(message) if socket
return unless @inbox.add?(message)
begin_delivery_timeout
end
|
#flush!(force = false) ⇒ Object
34
35
36
37
38
|
# File 'lib/faye/engines/connection.rb', line 34
def flush!(force = false)
release_connection!(force)
set_deferred_status(:succeeded, @inbox.entries)
@inbox = []
end
|