diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_cable/connection/internal_channel.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/action_cable/connection/internal_channel.rb b/lib/action_cable/connection/internal_channel.rb index 70e5e58373..baf916dffa 100644 --- a/lib/action_cable/connection/internal_channel.rb +++ b/lib/action_cable/connection/internal_channel.rb @@ -3,28 +3,28 @@ module ActionCable module InternalChannel extend ActiveSupport::Concern - def internal_redis_channel - "action_cable/#{connection_identifier}" - end + private + def internal_redis_channel + "action_cable/#{connection_identifier}" + end - def subscribe_to_internal_channel - if connection_identifier.present? - callback = -> (message) { process_internal_message(message) } - @_internal_redis_subscriptions ||= [] - @_internal_redis_subscriptions << [ internal_redis_channel, callback ] + def subscribe_to_internal_channel + if connection_identifier.present? + callback = -> (message) { process_internal_message(message) } + @_internal_redis_subscriptions ||= [] + @_internal_redis_subscriptions << [ internal_redis_channel, callback ] - pubsub.subscribe(internal_redis_channel, &callback) - logger.info "Registered connection (#{connection_identifier})" + pubsub.subscribe(internal_redis_channel, &callback) + logger.info "Registered connection (#{connection_identifier})" + end end - end - def unsubscribe_from_internal_channel - if @_internal_redis_subscriptions.present? - @_internal_redis_subscriptions.each { |channel, callback| pubsub.unsubscribe_proc(channel, callback) } + def unsubscribe_from_internal_channel + if @_internal_redis_subscriptions.present? + @_internal_redis_subscriptions.each { |channel, callback| pubsub.unsubscribe_proc(channel, callback) } + end end - end - private def process_internal_message(message) message = ActiveSupport::JSON.decode(message) |