Sha256: 4f067e80511da011f1c64842c784b12b5ab59bdc9a7aee77d38c5f2e71d76e4d
Contents?: true
Size: 1.45 KB
Versions: 6
Compression:
Stored size: 1.45 KB
Contents
module Faye module Engine MAX_DELAY = 0.0 INTERVAL = 0.0 TIMEOUT = 60.0 def self.register(type, klass) @backends ||= {} @backends[type] = klass end def self.get(options) options ||= {} klass = @backends[options[:type]] || Memory klass.new(options) end class Base include Logging attr_reader :interval, :timeout def initialize(options) @options = options @connections = {} @interval = @options[:interval] || INTERVAL @timeout = @options[:timeout] || TIMEOUT debug 'Created new engine: ?', @options end def connect(client_id, options = {}, &callback) debug 'Accepting connection from ?', client_id ping(client_id) conn = connection(client_id, true) conn.connect(options, &callback) empty_queue(client_id) end 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 def close_connection(client_id) debug 'Closing connection for ?', client_id @connections.delete(client_id) end def flush(client_id) debug 'Flushing message queue for ?', client_id conn = @connections[client_id] conn.flush! if conn end end end end
Version data entries
6 entries across 6 versions & 1 rubygems