Sha256: b6d4b85bd416c8d1121371c2fe3d7662b268dd93c5a9634794667ca44496cc71

Contents?: true

Size: 1.31 KB

Versions: 18

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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 ||= event_loop.timer(BEAT_INTERVAL) do
          event_loop.post { connections.each(&:beat) }
        end
      end

      def open_connections_statistics
        connections.map(&:statistics)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/actioncable-7.1.3.4/lib/action_cable/server/connections.rb
actioncable-7.1.5.1 lib/action_cable/server/connections.rb
actioncable-7.1.5 lib/action_cable/server/connections.rb
actioncable-7.1.4.2 lib/action_cable/server/connections.rb
actioncable-7.1.4.1 lib/action_cable/server/connections.rb
actioncable-7.1.4 lib/action_cable/server/connections.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actioncable-7.1.3.4/lib/action_cable/server/connections.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actioncable-7.1.3.4/lib/action_cable/server/connections.rb
actioncable-7.1.3.4 lib/action_cable/server/connections.rb
actioncable-7.1.3.2 lib/action_cable/server/connections.rb
actioncable-7.1.3.1 lib/action_cable/server/connections.rb
actioncable-7.1.3 lib/action_cable/server/connections.rb
actioncable-7.1.2 lib/action_cable/server/connections.rb
actioncable-7.1.1 lib/action_cable/server/connections.rb
actioncable-7.1.0 lib/action_cable/server/connections.rb
actioncable-7.1.0.rc2 lib/action_cable/server/connections.rb
actioncable-7.1.0.rc1 lib/action_cable/server/connections.rb
actioncable-7.1.0.beta1 lib/action_cable/server/connections.rb