Module: Rage::Cable::RemoteDisconnect

Defined in:
lib/rage/cable/remote_disconnect.rb

Overview

Include this module in your connection class to enable server-initiated disconnections.

This allows you to disconnect WebSocket connections from anywhere in your application using Rage::Cable::Connection.disconnect. A common use case is forcing a logout when a user's session is invalidated or their account is suspended.

Examples:

class RageCable::Connection < Rage::Cable::Connection
  include Rage::Cable::RemoteDisconnect

  identified_by :current_user

  def connect
    self.current_user = find_verified_user
  end
end

# Later, elsewhere in your application:
RageCable::Connection.disconnect(current_user: user)

Defined Under Namespace

Modules: ClassMethods