Class: ActionCable::SubscriptionAdapter::SolidCable
- Inherits:
-
Base
- Object
- Base
- ActionCable::SubscriptionAdapter::SolidCable
- Includes:
- ChannelPrefix
- Defined in:
- lib/action_cable/subscription_adapter/solid_cable.rb
Defined Under Namespace
Classes: Listener
Instance Method Summary collapse
- #broadcast(channel, payload) ⇒ Object
-
#initialize ⇒ SolidCable
constructor
A new instance of SolidCable.
- #subscribe(channel, callback, success_callback = nil) ⇒ Object
- #unsubscribe(channel, callback) ⇒ Object
Constructor Details
#initialize ⇒ SolidCable
Returns a new instance of SolidCable.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 13 def initialize(*) super @mutex = if defined?(@server) @server.mutex else Mutex.new end @listener = nil end |
Instance Method Details
#broadcast(channel, payload) ⇒ Object
25 26 27 28 29 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 25 def broadcast(channel, payload) ::SolidCable::Message.broadcast(channel, payload) ::SolidCable::TrimJob.perform_now if ::SolidCable.autotrim? end |
#subscribe(channel, callback, success_callback = nil) ⇒ Object
31 32 33 |
# File 'lib/action_cable/subscription_adapter/solid_cable.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 'lib/action_cable/subscription_adapter/solid_cable.rb', line 35 def unsubscribe(channel, callback) listener.remove_subscriber(channel, callback) end |