Class: Faye::Engine::Base
- Inherits:
-
Object
- Object
- Faye::Engine::Base
- Includes:
- Logging
- Defined in:
- lib/faye/engines/base.rb
Constant Summary
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary (collapse)
-
- (Object) interval
readonly
Returns the value of attribute interval.
-
- (Object) timeout
readonly
Returns the value of attribute timeout.
Attributes included from Logging
Instance Method Summary (collapse)
- - (Object) close_connection(client_id)
- - (Object) connect(client_id, options = {}, &callback)
- - (Object) connection(client_id, create)
- - (Object) flush(client_id)
-
- (Base) initialize(options)
constructor
A new instance of Base.
Methods included from Logging
Constructor Details
- (Base) initialize(options)
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
- (Object) interval (readonly)
Returns the value of attribute interval
22 23 24 |
# File 'lib/faye/engines/base.rb', line 22 def interval @interval end |
- (Object) timeout (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
- (Object) close_connection(client_id)
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 |
- (Object) connect(client_id, options = {}, &callback)
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 |
- (Object) connection(client_id, create)
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 |
- (Object) flush(client_id)
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 |