1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Never stop attempting to reconnect

This commit is contained in:
Pratik Naik 2015-02-26 15:52:45 -06:00
parent 359f006bac
commit d96ea7c5e4

View file

@ -2,7 +2,6 @@
#= require_tree .
class @Cable
MAX_CONNECTION_ATTEMPTS: 10
MAX_CONNECTION_INTERVAL: 5 * 1000
PING_STALE_INTERVAL: 6
@ -53,11 +52,8 @@ class @Cable
@disconnected()
setTimeout =>
if @isMaxConnectionAttemptsReached()
@giveUp()
else
@incrementConnectionAttemptsCount()
@connect()
@incrementConnectionAttemptsCount()
@connect()
, @generateReconnectInterval()
resetConnectionAttemptsCount: =>
@ -66,9 +62,6 @@ class @Cable
incrementConnectionAttemptsCount: =>
@connectionAttempts += 1
isMaxConnectionAttemptsReached: =>
@connectionAttempts > @MAX_CONNECTION_ATTEMPTS
generateReconnectInterval: () ->
interval = (Math.pow(2, @connectionAttempts) - 1) * 1000
if interval > @MAX_CONNECTION_INTERVAL then @MAX_CONNECTION_INTERVAL else interval