Sha256: 3c143582fe4ba5e64f85a512a98121f0686e8d6874b85a023da1ddd196d9164a
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true # :markup: markdown module ActionCable module Server # # Action Cable Server Connections # # Collection class for all the connections that have been established on this # specific server. Remember, usually you'll run many Action Cable servers, so # you can't use this collection as a full list of all of the connections # established against your application. Instead, use RemoteConnections for that. module Connections # :nodoc: BEAT_INTERVAL = 3 def connections @connections ||= [] end def add_connection(connection) connections << connection end def remove_connection(connection) connections.delete connection end # WebSocket connection implementations differ on when they'll mark a connection # as stale. We basically never want a connection to go stale, as you then can't # rely on being able to communicate with the connection. To solve this, a 3 # second heartbeat runs on all connections. If the beat fails, we automatically # disconnect. def setup_heartbeat_timer @heartbeat_timer ||= executor.timer(BEAT_INTERVAL) do executor.post { connections.each(&:beat) } end end def open_connections_statistics connections.map(&:statistics) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
actioncable-next-0.1.2 | lib/action_cable/server/connections.rb |
actioncable-next-0.1.1 | lib/action_cable/server/connections.rb |
actioncable-next-0.1.0 | lib/action_cable/server/connections.rb |