Class: ActionCable::SubscriptionAdapter::Redis
- Includes:
- ChannelPrefix
- Defined in:
- lib/action_cable/subscription_adapter/redis.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Listener
Instance Method Summary collapse
- #broadcast(channel, payload) ⇒ Object
-
#initialize ⇒ Redis
constructor
A new instance of Redis.
- #redis_connection_for_subscriptions ⇒ Object
- #shutdown ⇒ Object
- #subscribe(channel, callback, success_callback = nil) ⇒ Object
- #unsubscribe(channel, callback) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Redis
Returns a new instance of Redis.
22 23 24 25 26 27 |
# File 'lib/action_cable/subscription_adapter/redis.rb', line 22 def initialize(*) super @listener = nil @mutex = Mutex.new @redis_connection_for_broadcasts = nil end |
Instance Method Details
#broadcast(channel, payload) ⇒ Object
29 30 31 |
# File 'lib/action_cable/subscription_adapter/redis.rb', line 29 def broadcast(channel, payload) redis_connection_for_broadcasts.publish(channel, payload) end |
#redis_connection_for_subscriptions ⇒ Object
45 46 47 |
# File 'lib/action_cable/subscription_adapter/redis.rb', line 45 def redis_connection_for_subscriptions redis_connection end |
#shutdown ⇒ Object
41 42 43 |
# File 'lib/action_cable/subscription_adapter/redis.rb', line 41 def shutdown @listener.shutdown if @listener end |
#subscribe(channel, callback, success_callback = nil) ⇒ Object
33 34 35 |
# File 'lib/action_cable/subscription_adapter/redis.rb', line 33 def subscribe(channel, callback, success_callback = nil) listener.add_subscriber(channel, callback, success_callback) end |
#unsubscribe(channel, callback) ⇒ Object
37 38 39 |
# File 'lib/action_cable/subscription_adapter/redis.rb', line 37 def unsubscribe(channel, callback) listener.remove_subscriber(channel, callback) end |