Sha256: cab4e9dbcf5809edd11717ac1879b670e212c1862d95cd37750dabd6941be53a

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

class Firehose.Transport
  # 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: (config={}) ->
    @config = config
    @_retryDelay = 5000 

  # Lets rock'n'roll! Connect to the server.
  connect: (delay = 0) =>
    setTimeout =>
      @_request()
    , delay
    this

  # Sub classes need to implement this method to handle requests
  _request: =>

  # Default error handler
  _error: (event) =>
    # Lets try to connect again with delay
    @config.disconnected()
    @connect(@_retryDelay)

  # Default connection established handler
  _open: (event) =>
    @config.connected()

  # Default connection closed handler
  _close: (event) =>
    @config.disconnected()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
firehose-0.0.9 lib/assets/javascripts/firehose/transport.js.coffee