Class: ActionCable::SubscriptionAdapter::Redis
- Defined in:
- actioncable/lib/action_cable/subscription_adapter/redis.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Listener
Instance Attribute Summary
Attributes inherited from Base
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.
21 22 23 24 25 |
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 21 def initialize(*) super @listener = nil @redis_connection_for_broadcasts = nil end |
Instance Method Details
#broadcast(channel, payload) ⇒ Object
27 28 29 |
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 27 def broadcast(channel, payload) redis_connection_for_broadcasts.publish(channel, payload) end |
#redis_connection_for_subscriptions ⇒ Object
43 44 45 |
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 43 def redis_connection_for_subscriptions redis_connection end |
#shutdown ⇒ Object
39 40 41 |
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 39 def shutdown @listener.shutdown if @listener end |
#subscribe(channel, callback, success_callback = nil) ⇒ Object
31 32 33 |
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 31 def subscribe(channel, callback, success_callback = nil) listener.add_subscriber(channel, callback, success_callback) end |
#unsubscribe(channel, callback) ⇒ Object
35 36 37 |
# File 'actioncable/lib/action_cable/subscription_adapter/redis.rb', line 35 def unsubscribe(channel, callback) listener.remove_subscriber(channel, callback) end |