aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/app/assets/javascripts/action_cable/connection.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/app/assets/javascripts/action_cable/connection.coffee')
-rw-r--r--actioncable/app/assets/javascripts/action_cable/connection.coffee13
1 files changed, 5 insertions, 8 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee
index 25793ea3d3..9be5cdf5fb 100644
--- a/actioncable/app/assets/javascripts/action_cable/connection.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee
@@ -8,9 +8,6 @@ class ActionCable.Connection
constructor: (@consumer) ->
send: (data) ->
- unless @isOpen()
- @open()
-
if @isOpen()
@webSocket.send(JSON.stringify(data))
true
@@ -18,7 +15,7 @@ class ActionCable.Connection
false
open: =>
- if @isAlive()
+ if @isActive()
ActionCable.log("Attemped to open WebSocket, but existing socket is #{@getState()}")
throw new Error("Existing connection must be closed before opening")
else
@@ -33,7 +30,7 @@ class ActionCable.Connection
reopen: ->
ActionCable.log("Reopening WebSocket, current state is #{@getState()}")
- if @isAlive()
+ if @isActive()
try
@close()
catch error
@@ -47,10 +44,10 @@ class ActionCable.Connection
isOpen: ->
@isState("open")
- # Private
+ isActive: ->
+ @isState("open", "connecting")
- isAlive: ->
- @webSocket? and not @isState("closing", "closed")
+ # Private
isState: (states...) ->
@getState() in states