Class: Faye::Engine::Connection
- Inherits:
-
Object
- Object
- Faye::Engine::Connection
show all
- Includes:
- Deferrable, Timeouts
- Defined in:
- lib/faye/engines/connection.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Timeouts
#add_timeout, #remove_all_timeouts, #remove_timeout
Methods included from Deferrable
#set_deferred_status
Constructor Details
#initialize(engine, id, options = {}) ⇒ 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
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/faye/engines/connection.rb', line 24
def connect(options, &block)
options = options || {}
timeout = options['timeout'] ? options['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(message)
message.delete('clientId')
return @socket.send(message) if @socket
return unless @inbox.add?(message)
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
|