aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/app/assets/javascripts/action_cable/consumer.coffee
diff options
context:
space:
mode:
authorJavan Makhmali <javan@javan.us>2016-03-03 17:33:56 -0500
committerJavan Makhmali <javan@javan.us>2016-03-03 17:59:12 -0500
commit82a1bf268d289cd647f681ce5c92c6b1efedd816 (patch)
tree4534ae4c9a14b87f711866265609e6529a13353e /actioncable/app/assets/javascripts/action_cable/consumer.coffee
parentdaeaac702795f2ab6bb882abef1a349b1b799b22 (diff)
downloadrails-82a1bf268d289cd647f681ce5c92c6b1efedd816.tar.gz
rails-82a1bf268d289cd647f681ce5c92c6b1efedd816.tar.bz2
rails-82a1bf268d289cd647f681ce5c92c6b1efedd816.zip
Establish WebSocket connection when first subscription is created. Fixes #24026
* More intention revealing than connecting on the first call to Connection#send * Fixes that calls to Connection#send would attempt to open a connection when the WebSocket's state is CONNECTING
Diffstat (limited to 'actioncable/app/assets/javascripts/action_cable/consumer.coffee')
-rw-r--r--actioncable/app/assets/javascripts/action_cable/consumer.coffee4
1 files changed, 4 insertions, 0 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable/consumer.coffee b/actioncable/app/assets/javascripts/action_cable/consumer.coffee
index 717c0641a9..3d93d40b99 100644
--- a/actioncable/app/assets/javascripts/action_cable/consumer.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/consumer.coffee
@@ -23,3 +23,7 @@ class ActionCable.Consumer
send: (data) ->
@connection.send(data)
+
+ ensureActiveConnection: ->
+ unless @connection.isActive()
+ @connection.open()