diff options
-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") |