From 1afd414488fe73c927242e072af0ff9ab21d2599 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 24 Feb 2016 18:36:55 -0500 Subject: Only open Action Cable connection if data is being sent --- actioncable/app/assets/javascripts/action_cable/connection.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actioncable/app') diff --git a/actioncable/app/assets/javascripts/action_cable/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee index ee888f567b..4244322a1e 100644 --- a/actioncable/app/assets/javascripts/action_cable/connection.coffee +++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee @@ -6,9 +6,11 @@ class ActionCable.Connection @reopenDelay: 500 constructor: (@consumer) -> - @open() send: (data) -> + unless @isOpen() + @open() + if @isOpen() @webSocket.send(JSON.stringify(data)) true -- cgit v1.2.3