From 404867d332069d8b87547e1eae5ed1d0a7a1b95c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 20 Jun 2015 16:21:21 +0200 Subject: TOC order --- lib/action_cable/channel/base.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/action_cable/channel/base.rb') diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 6060ccf681..c39c2fcf0b 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -31,6 +31,12 @@ module ActionCable perform_connection end + def perform_connection + logger.info "#{channel_name} connecting" + connect + run_subscribe_callbacks + end + def perform_action(data) if authorized? action = extract_action(data) @@ -52,11 +58,6 @@ module ActionCable logger.info "#{channel_name} disconnected" end - def perform_connection - logger.info "#{channel_name} connecting" - connect - run_subscribe_callbacks - end protected # Override in subclasses -- cgit v1.2.3 From 294a277a8409e05c6b98cd8e46a8e0745f68b40d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 20 Jun 2015 16:22:40 +0200 Subject: Rename broadcast to transmit for the connection/channel->subscriber communication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Disambiguate it from the broadcast to channel method used by the broadcaster (which actually has several listeners, whereas a connection/channel instance only ever has one listener – hence not much of a BROADcast). --- lib/action_cable/channel/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/action_cable/channel/base.rb') diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index c39c2fcf0b..4c90849a06 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -79,10 +79,10 @@ module ActionCable end - def broadcast(data) + def transmit(data, via: nil) if authorized? - logger.info "#{channel_name} broadcasting #{data.inspect}" - connection.broadcast({ identifier: @channel_identifier, message: data }.to_json) + logger.info "#{channel_name} transmitting #{data.inspect} #{via}" + connection.transmit({ identifier: @channel_identifier, message: data }.to_json) else unauthorized end -- cgit v1.2.3 From 995c101caae06ec38d0106dcd9ee36954a489687 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 20 Jun 2015 16:51:11 +0200 Subject: More logging improvements --- lib/action_cable/channel/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/action_cable/channel/base.rb') diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 4c90849a06..e6ca45ddcc 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -81,7 +81,7 @@ module ActionCable def transmit(data, via: nil) if authorized? - logger.info "#{channel_name} transmitting #{data.inspect} #{via}" + logger.info "#{channel_name} transmitting #{data.inspect}".tap { |m| m << " (via #{via})" if via } connection.transmit({ identifier: @channel_identifier, message: data }.to_json) else unauthorized -- cgit v1.2.3