Class: BrowserChannel::Server
- Inherits:
-
Object
- Object
- BrowserChannel::Server
- Defined in:
- lib/browser_channel.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/browser_channel.rb', line 21 def initialize ={} = { # Subclass this echo Handler or create your own. :handler => Handler, # Ensure a chunk is sent within these first few seconds because # waiting an entire interval looks too much like a broken server. :keep_alive_first => 10, # Send a noop chunk every so many seconds to prevent timeouts. :keep_alive_interval => 30, # Alternate host prefix for clients with connection pool limits. :host_prefix => nil, # Number of seconds a session must be unbound before freed. :gc_max_age => 120, # Minimum number of seconds to wait between garbage collections. :gc_frequency => 10, }.merge! errors = [] unless [:gc_max_age] > ([:keep_alive_interval] - [:keep_alive_first]) # in this condition, connections look expired on creation errors << 'gc_max_age is too small' end if [:keep_alive_interval] < [:keep_alive_first] errors << 'keep_alive_first must be same or smaller than keep_alive_interval' end raise "Options Fail: #{errors.join(', ')}." unless errors.empty? end |
Instance Method Details
#call(env) ⇒ Object
47 48 49 50 |
# File 'lib/browser_channel.rb', line 47 def call env BrowserChannel.new , env Thin::Connection::AsyncResponse end |