diff options
Diffstat (limited to 'actioncable/app/assets/javascripts')
-rw-r--r-- | actioncable/app/assets/javascripts/action_cable/connection.coffee | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee index 866bb20870..b1343a111c 100644 --- a/actioncable/app/assets/javascripts/action_cable/connection.coffee +++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee @@ -16,11 +16,11 @@ class ActionCable.Connection false open: => - if @webSocket and not @isState("closed") + if @webSocket and not @isClosed() console.log("[cable] Attemped to open WebSocket, but existing socket is #{@getState()}", Date.now()) throw new Error("Existing connection must be closed before opening") else - console.log("[cable] Opening WebSocket", Date.now()) + console.log("[cable] Opening WebSocket, current state is #{@getState()}", Date.now()) @webSocket = new WebSocket(@consumer.url) @installEventHandlers() true @@ -30,7 +30,7 @@ class ActionCable.Connection reopen: -> console.log("[cable] Reopening WebSocket, current state is #{@getState()}", Date.now()) - if @isState("closed") + if @isClosed() @open() else try @@ -44,6 +44,9 @@ class ActionCable.Connection # Private + isClosed: -> + @isState("closing", "closed") + isState: (states...) -> @getState() in states |