Class: Rage::Configuration::Cable

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allowed_request_originsArray<Regexp>, ...

Restrict the server to only accept requests from specified origins. The origins can be strings or regular expressions. Defaults to /localhost/ in development and test environments.

Examples:

Rage.configure do
  config.cable.allowed_request_origins = [/example\.com/, "myapp.com"]
end

Returns:

  • (Array<Regexp>, Regexp, Array<String>, String, nil)


479
480
481
# File 'lib/rage/configuration.rb', line 479

def allowed_request_origins
  @allowed_request_origins
end

#disable_request_forgery_protectionBoolean

Disable request forgery protection for WebSocket connections to allow requests from any origin.

Examples:

Rage.configure do
  config.cable.disable_request_forgery_protection = true
end

Returns:

  • (Boolean)


479
# File 'lib/rage/configuration.rb', line 479

attr_accessor :allowed_request_origins, :disable_request_forgery_protection

Instance Method Details

#protocolClass

Returns the protocol the server will use.

Returns:

  • (Class)

    the protocol class



491
492
493
# File 'lib/rage/configuration.rb', line 491

def protocol
  @protocol
end

#protocol=(protocol) ⇒ Object

Specify the protocol the server will use. Supported values include :actioncable_v1_json and :raw_websocket_json. Defaults to :actioncable_v1_json.

Examples:

Use the built-in ActionCable V1 JSON protocol

Rage.configure do
  config.cable.protocol = :actioncable_v1_json
end

Use the built-in Raw WebSocket JSON protocol

Rage.configure do
  config.cable.protocol = :raw_websocket_json
end

Parameters:

  • protocol (:actioncable_v1_json, :raw_websocket_json)

    the protocol symbol



505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/rage/configuration.rb', line 505

def protocol=(protocol)
  @protocol = case protocol
  when Class
    protocol
  when :actioncable_v1_json
    Rage::Cable::Protocols::ActioncableV1Json
  when :raw_websocket_json
    Rage::Cable::Protocols::RawWebSocketJson
  else
    raise ArgumentError, "Unknown protocol. Supported values are `:actioncable_v1_json` and `:raw_websocket_json`."
  end
end