From 506d84c157b041208f40b7034cac9c5d5e66fff5 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 19 Oct 2015 15:14:22 -0500 Subject: Make sure the subscription confirmaion is only sent out once --- lib/action_cable/channel/base.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/action_cable') diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 0b9aa2f4ad..221730dbc4 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -180,6 +180,10 @@ module ActionCable @defer_subscription_confirmation end + def subscription_confirmation_sent? + @subscription_confirmation_sent + end + private def delegate_connection_identifiers connection.identifiers.each do |identifier| @@ -231,8 +235,12 @@ module ActionCable end def transmit_subscription_confirmation - logger.info "#{self.class.name} is transmitting the subscription confirmation" - connection.transmit ActiveSupport::JSON.encode(identifier: @identifier, type: SUBSCRIPTION_CONFIRMATION_INTERNAL_MESSAGE) + unless subscription_confirmation_sent? + logger.info "#{self.class.name} is transmitting the subscription confirmation" + connection.transmit ActiveSupport::JSON.encode(identifier: @identifier, type: SUBSCRIPTION_CONFIRMATION_INTERNAL_MESSAGE) + + @subscription_confirmation_sent = true + end end end -- cgit v1.2.3