Skip to content

Commit

Permalink
Add delay before reopening
Browse files Browse the repository at this point in the history
  • Loading branch information
javan committed Oct 14, 2015
1 parent e079727 commit e8e6937
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/assets/javascripts/cable/connection.coffee
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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")
Expand Down

0 comments on commit e8e6937

Please sign in to comment.