diff options
author | Javan Makhmali <javan@javan.us> | 2015-10-14 17:09:10 -0500 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2015-10-14 17:09:10 -0500 |
commit | e8e6937d96f969c16011f3e1f136d6b8c21f8c97 (patch) | |
tree | a47590cf42eb2c3a5d16ee4aee937531e07d69fc | |
parent | e07972711ed9e9404d4e6051c1ad23275a6d6645 (diff) | |
download | rails-e8e6937d96f969c16011f3e1f136d6b8c21f8c97.tar.gz rails-e8e6937d96f969c16011f3e1f136d6b8c21f8c97.tar.bz2 rails-e8e6937d96f969c16011f3e1f136d6b8c21f8c97.zip |
Add delay before reopening
-rw-r--r-- | lib/assets/javascripts/cable/connection.coffee | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/assets/javascripts/cable/connection.coffee b/lib/assets/javascripts/cable/connection.coffee index 8256f731c5..801b3d97b1 100644 --- a/lib/assets/javascripts/cable/connection.coffee +++ b/lib/assets/javascripts/cable/connection.coffee @@ -1,5 +1,7 @@ # Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation. class Cable.Connection + @reopenDelay: 500 + constructor: (@consumer) -> @open() @@ -22,8 +24,13 @@ class Cable.Connection @webSocket?.close() reopen: -> - @close() - @open() + if @isState("closed") + @open() + else + try + @close() + finally + setTimeout(@open, @constructor.reopenDelay) isOpen: -> @isState("open") |