Sha256: 46d954805bc635de055146bbef8f508820ef237325f540da7905cdd76344280d

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 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

  # Hey subclasses:
  name: ->     throw 'not implemented in base Transport' # implement this to identify transport type
  stop: ->     throw 'not implemented in base Transport' # implement this to stop receiving messages
  _request: -> throw 'not implemented in base Transport' # implement this to handle requests

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
firehose-1.0.0 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.2.alpha.10 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.2.alpha.9 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.2.alpha.8 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.2.alpha.7 lib/assets/javascripts/firehose/transport.js.coffee
firehose-0.2.alpha.6 lib/assets/javascripts/firehose/transport.js.coffee