lib/assets/javascripts/firehose/transport.js.coffee in firehose-0.2.alpha.5 vs lib/assets/javascripts/firehose/transport.js.coffee in firehose-0.2.alpha.6
- old
+ new
@@ -9,26 +9,24 @@
@config = config
@_retryDelay = 5000
# Lets rock'n'roll! Connect to the server.
connect: (delay = 0) =>
- setTimeout =>
- @_request()
- , delay
+ setTimeout @_request, delay
this
- # Sub classes need to implement this method to handle requests
- _request: =>
+ # 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) =>
- unless @_succeeded
- # Fail peremantly if the error happens on the first connection.
- @config.failed(this)
- else
+ 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(@)
\ No newline at end of file