From a5d6bc0eb527f6cfa61300e70fa9010544240cf9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 28 Jun 2015 20:38:05 +0200 Subject: [PATCH] Make the remote connection use the broadcaster as well --- lib/action_cable/remote_connection.rb | 10 ++++------ lib/action_cable/server/broadcasting.rb | 8 ++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/action_cable/remote_connection.rb b/lib/action_cable/remote_connection.rb index b6fdf226e3..d7a3f0125d 100644 --- a/lib/action_cable/remote_connection.rb +++ b/lib/action_cable/remote_connection.rb @@ -10,18 +10,16 @@ module ActionCable end def disconnect - redis.publish internal_redis_channel, { type: 'disconnect' }.to_json + server.broadcast_without_logging internal_redis_channel, type: 'disconnect' end def identifiers - @server.connection_identifiers - end - - def redis - @server.threaded_redis + server.connection_identifiers end private + attr_reader :server + def set_identifier_instance_vars(ids) raise InvalidIdentifiersError unless valid_identifiers?(ids) ids.each { |k,v| instance_variable_set("@#{k}", v) } diff --git a/lib/action_cable/server/broadcasting.rb b/lib/action_cable/server/broadcasting.rb index 691ec1b486..0d591d03e4 100644 --- a/lib/action_cable/server/broadcasting.rb +++ b/lib/action_cable/server/broadcasting.rb @@ -19,8 +19,12 @@ module ActionCable @server, @channel = server, channel end - def broadcast(message, log: true) - server.logger.info "[ActionCable] Broadcasting to #{channel}: #{message}" if log + def broadcast(message) + server.logger.info "[ActionCable] Broadcasting to #{channel}: #{message}" + broadcast_without_logging(message) + end + + def broadcast_without_logging(message) server.redis_for_threads.publish channel, message.to_json end