Class: ActionCable::RemoteConnections::RemoteConnection
Relationships & Source Files | |
Namespace Children | |
Exceptions:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | actioncable/lib/action_cable/remote_connections.rb |
Overview
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.
::ActionCable::Connection::Identification
- Attributes & Methods
Class Method Summary
- .new(server, ids) ⇒ RemoteConnection constructor
Instance Attribute Summary
- #server readonly protected
Instance Method Summary
-
#disconnect(reconnect: true)
Uses the internal channel to disconnect the connection.
- #set_identifier_instance_vars(ids) private
- #valid_identifiers?(ids) ⇒ Boolean private
::ActionCable::Connection::Identification
- Included
#connection_identifier | Return a single connection identifier that combines the value of all the registered identifiers into a single gid. |
#connection_gid |
::ActionCable::Connection::InternalChannel
- Included
Constructor Details
.new(server, ids) ⇒ RemoteConnection
# File 'actioncable/lib/action_cable/remote_connections.rb', line 52
def initialize(server, ids) @server = server set_identifier_instance_vars(ids) end
Class Attribute Details
.identifiers (rw)
[ GitHub ]# File 'actioncable/lib/action_cable/connection/identification.rb', line 11
class_attribute :identifiers, default: Set.new
.identifiers? ⇒ Boolean
(rw)
[ GitHub ]
# File 'actioncable/lib/action_cable/connection/identification.rb', line 11
class_attribute :identifiers, default: Set.new
Instance Attribute Details
#identifiers (rw)
[ GitHub ]# File 'actioncable/lib/action_cable/connection/identification.rb', line 11
class_attribute :identifiers, default: Set.new
#identifiers? ⇒ Boolean
(rw)
[ GitHub ]
# File 'actioncable/lib/action_cable/connection/identification.rb', line 11
class_attribute :identifiers, default: Set.new
#server (readonly, protected)
[ GitHub ]# File 'actioncable/lib/action_cable/remote_connections.rb', line 68
attr_reader :server
Instance Method Details
#disconnect(reconnect: true)
Uses the internal channel to disconnect the connection.
# File 'actioncable/lib/action_cable/remote_connections.rb', line 58
def disconnect(reconnect: true) server.broadcast internal_channel, { type: "disconnect", reconnect: reconnect } end
#set_identifier_instance_vars(ids) (private)
# File 'actioncable/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
#valid_identifiers?(ids) ⇒ Boolean
(private)
# File 'actioncable/lib/action_cable/remote_connections.rb', line 76
def valid_identifiers?(ids) keys = ids.keys identifiers.all? { |id| keys.include?(id) } end