Class: Faye::Engine::Base
- Inherits:
-
Object
- Object
- Faye::Engine::Base
- Includes:
- Logging
- Defined in:
- lib/faye/engines/base.rb
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Attributes included from Logging
Instance Method Summary collapse
- #close_connection(client_id) ⇒ Object
- #connect(client_id, options = {}, &callback) ⇒ Object
- #connection(client_id, create) ⇒ Object
- #flush(client_id) ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
Methods included from Logging
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 31 |
# File 'lib/faye/engines/base.rb', line 24 def initialize() @options = @connections = {} @interval = @options[:interval] || INTERVAL @timeout = @options[:timeout] || TIMEOUT debug 'Created new engine: ?', @options end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
22 23 24 |
# File 'lib/faye/engines/base.rb', line 22 def interval @interval end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
22 23 24 |
# File 'lib/faye/engines/base.rb', line 22 def timeout @timeout end |
Instance Method Details
#close_connection(client_id) ⇒ Object
47 48 49 50 |
# File 'lib/faye/engines/base.rb', line 47 def close_connection(client_id) debug 'Closing connection for ?', client_id @connections.delete(client_id) end |
#connect(client_id, options = {}, &callback) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/faye/engines/base.rb', line 33 def connect(client_id, = {}, &callback) debug 'Accepting connection from ?', client_id ping(client_id) conn = connection(client_id, true) conn.connect(, &callback) empty_queue(client_id) end |
#connection(client_id, create) ⇒ Object
41 42 43 44 45 |
# File 'lib/faye/engines/base.rb', line 41 def connection(client_id, create) conn = @connections[client_id] return conn if conn or not create @connections[client_id] = Connection.new(self, client_id) end |
#flush(client_id) ⇒ Object
52 53 54 55 56 |
# File 'lib/faye/engines/base.rb', line 52 def flush(client_id) debug 'Flushing message queue for ?', client_id conn = @connections[client_id] conn.flush! if conn end |