123456789_123456789_123456789_123456789_123456789_

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

Instance Attribute Summary

Instance Method Summary

::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

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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)

[ GitHub ]

  
# 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)

[ GitHub ]

  
# File 'actioncable/lib/action_cable/remote_connections.rb', line 76

def valid_identifiers?(ids)
  keys = ids.keys
  identifiers.all? { |id| keys.include?(id) }
end