Class: ActionCable::SubscriptionAdapter::SolidCable::Listener
- Inherits:
-
ActionCable::SubscriptionAdapter::SubscriberMap
- Object
- ActionCable::SubscriptionAdapter::SubscriberMap
- ActionCable::SubscriptionAdapter::SolidCable::Listener
- Defined in:
- lib/action_cable/subscription_adapter/solid_cable.rb
Instance Method Summary collapse
- #add_channel(channel, on_success) ⇒ Object
-
#initialize(event_loop) ⇒ Listener
constructor
A new instance of Listener.
- #invoke_callback ⇒ Object
- #listen ⇒ Object
- #remove_channel(channel) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(event_loop) ⇒ Listener
Returns a new instance of Listener.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 41 def initialize(event_loop) super() @event_loop = event_loop @thread = Thread.new do Thread.current.abort_on_exception = true listen end end |
Instance Method Details
#add_channel(channel, on_success) ⇒ Object
65 66 67 68 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 65 def add_channel(channel, on_success) channels.add(channel) event_loop.post(&on_success) if on_success end |
#invoke_callback ⇒ Object
74 75 76 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 74 def invoke_callback(*) event_loop.post { super } end |
#listen ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 52 def listen while running? with_polling_volume { } sleep ::SolidCable.polling_interval end end |
#remove_channel(channel) ⇒ Object
70 71 72 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 70 def remove_channel(channel) channels.delete(channel) end |
#shutdown ⇒ Object
60 61 62 63 |
# File 'lib/action_cable/subscription_adapter/solid_cable.rb', line 60 def shutdown self.running = false Thread.pass while thread.alive? end |