Module: RailsLiveReload::Server::Connections
- Included in:
- Base
- Defined in:
- lib/rails_live_reload/server/connections.rb
Overview
This class is strongly based on ActionCable github.com/rails/rails/blob/v7.0.3/actioncable/lib/action_cable/server/connections.rb
Constant Summary collapse
- BEAT_INTERVAL =
3
Instance Method Summary collapse
- #add_connection(connection) ⇒ Object
- #connections ⇒ Object
- #remove_connection(connection) ⇒ Object
- #setup_heartbeat_timer ⇒ Object
Instance Method Details
#add_connection(connection) ⇒ Object
12 13 14 |
# File 'lib/rails_live_reload/server/connections.rb', line 12 def add_connection(connection) connections << connection end |
#connections ⇒ Object
8 9 10 |
# File 'lib/rails_live_reload/server/connections.rb', line 8 def connections @connections || @mutex.synchronize { @connections ||= Concurrent::Array.new } end |
#remove_connection(connection) ⇒ Object
16 17 18 |
# File 'lib/rails_live_reload/server/connections.rb', line 16 def remove_connection(connection) connections.delete connection end |
#setup_heartbeat_timer ⇒ Object
20 21 22 23 24 |
# File 'lib/rails_live_reload/server/connections.rb', line 20 def setup_heartbeat_timer @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do event_loop.post { connections.each(&:beat) } end end |