class

ActionCable::Connection

Inherits ActionCable::ConnectionAPI < Reference < Object

Constants

PING_INTERVAL = 3.seconds

Constructors

new(io : IO, server : Server, request : HTTP::Request | Nil = nil)
Source

Instance methods

buffered_amount
Source
close_connection(reason : String | Nil = nil, reconnect : Bool = true) : Nil

Sends the disconnect frame (type/reason/reconnect) and starts the WS close handshake — the gem's Connection#close.

Source
connect

Override (subclass or reopen) — called once on open, before the welcome message; set identifier values here.

Source
connection_identifier

Single gid combining all registered identifier values, sorted and colon-joined (gem's Connection#connection_identifier); nil when no identifier has a value.

Source
deliver_text(text : String) : Nil

Fast-path delivery: prebuilt envelope bytes from the adapter.

Source
disconnect

Override — called once the socket has closed, after channels and the internal channel are unsubscribed.

Source
dropped_messages
Source
identifiers

--- ConnectionAPI (channel seam) --------------------------------

Source
internal_channel

--- internal channel (gem's Connection::InternalChannel) --------- Per-connection pubsub channel the remote-connections disconnect message arrives on: "action_cable/<connection_identifier>".

Source
pubsub
Source
reject_unauthorized_connection!

raise UnauthorizedConnectionError из connect-хука — отвергнуть соединение (gem: reject_unauthorized_connection!).

Source
request

Upgrade-запрос (доступен, когда connection создан ws_handler'ом; в юнит-тестах может не быть).

Source
request_cookies

Cookie-заголовки upgrade-запроса (gem: request.cookies через ActionDispatch::Cookies в connection).

Source
session

Верифицированная cookie-сессия фазы C (подписанный crails_session, legacy-конверт + SHA1): значение warden-ключа devise и т.п. Доступно в connect-хуке приложения:

def connect reject_unauthorized_connection! unless session["warden.user.user.key"]? self.current_user = ... end

Source
subscribe_stream(stream : String, identifier : String) : Nil

--- fast-path subscription seam (P1.5) ---------------------------

Source
transmit(cable : Hash(String | Symbol, CableValue)) : Nil
Source
unsubscribe_stream(stream : String) : Nil
Source

Macros

identified_by(*names)

--- identified_by (gem's Connection::Identification) ------------- Marks a key as a connection identifier index so the connection can be found later, e.g. for remote disconnect:

class ActionCable::Connection identified_by :current_user end

Deviation: identifier values are Strings (the gid of an AR object is its to_gid_param string anyway).

Source