class ActionCable::RemoteConnections::RemoteConnection
Action Cable Remote Connection
¶ ↑
Represents a single remote connection found via ActionCable.server.remote_connections.where(*)
. Exists solely for the purpose of calling disconnect
on that connection.
Attributes
Public Class Methods
Source
# File lib/action_cable/remote_connections.rb, line 52 def initialize(server, ids) @server = server set_identifier_instance_vars(ids) end
Public Instance Methods
Source
# File lib/action_cable/remote_connections.rb, line 58 def disconnect(reconnect: true) server.broadcast internal_channel, { type: "disconnect", reconnect: reconnect } end
Uses the internal channel to disconnect the connection.
Private Instance Methods
Source
# File lib/action_cable/remote_connections.rb, line 71 def set_identifier_instance_vars(ids) raise InvalidIdentifiersError unless valid_identifiers?(ids) ids.each { |k, v| instance_variable_set("@#{k}", v) } end
Source
# File lib/action_cable/remote_connections.rb, line 76 def valid_identifiers?(ids) keys = ids.keys identifiers.all? { |id| keys.include?(id) } end