aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/action_cable/channel/redis.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/action_cable/channel/redis.rb b/lib/action_cable/channel/redis.rb
index 215cc3c975..00a8230a74 100644
--- a/lib/action_cable/channel/redis.rb
+++ b/lib/action_cable/channel/redis.rb
@@ -10,21 +10,22 @@ module ActionCable
def subscribe_to(redis_channel, callback = nil)
@_redis_channels ||= []
- @_redis_channels << redis_channel
callback ||= -> (message) { broadcast ActiveSupport::JSON.decode(message) }
- redis.pubsub.subscribe(redis_channel, &callback)
+ @_redis_channels << [ redis_channel, callback ]
+
+ pubsub.subscribe(redis_channel, &callback)
end
protected
def unsubscribe_from_redis_channels
if @_redis_channels
- @_redis_channels.each { |channel| @connection.pubsub.unsubscribe(channel) }
+ @_redis_channels.each { |channel, callback| pubsub.unsubscribe_proc(channel, callback) }
end
end
- def redis
- @connection.redis
+ def pubsub
+ @connection.class.pubsub
end
end