lib/assets/javascripts/firehose/transport.js.coffee in firehose-0.0.8 vs lib/assets/javascripts/firehose/transport.js.coffee in firehose-0.0.9

- old
+ new

@@ -1,23 +1,17 @@ class Firehose.Transport - # Class method to determine whether transport is supported by the current browser + # Class method to determine whether transport is supported by the current browser. Note that while + # the transport may be supported by the browser, its possible that the network connection won't + # succeed. That should be accounted for during the initial connecting to the server. @supported: => false - constructor: (args) -> - @_errorInterval = 5000 + constructor: (config={}) -> + @config = config + @_retryDelay = 5000 - # Chainable config - connected: (@onConnected) -> this - disconnected: (@onDisconnected) -> this - message: (@onMessage) -> this - error: (@onError) -> this - url: (@url) -> this - params: (@params) -> this - options: (@options) -> this - - # Lets rock'n'roll + # Lets rock'n'roll! Connect to the server. connect: (delay = 0) => setTimeout => @_request() , delay this @@ -26,15 +20,15 @@ _request: => # Default error handler _error: (event) => # Lets try to connect again with delay - @onDisconnected() - @connect(@_errorInterval) + @config.disconnected() + @connect(@_retryDelay) # Default connection established handler _open: (event) => - @onConnected() + @config.connected() # Default connection closed handler _close: (event) => - @onDisconnected() + @config.disconnected() \ No newline at end of file