Sha256: 01bc8d38690b3004d203b36ab6db808f3065635606968df951527f443a275a2b

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

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) =>
    unless @_succeeded
      # Fail peremantly if the error happens on the first connection.
      @config.failed(this)
    else
      # Lets try to connect again with delay
      @config.disconnected()
      @connect(@_retryDelay)

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
firehose-0.1.1 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.1.0 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.16 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.15 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.14 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.13 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.12 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.11 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.0.10 lib/assets/javascripts/firehose/transport.js.coffee