Module: LiteCable::AnyCable::Connection::InstanceMethods
- Defined in:
- lib/lite_cable/anycable.rb
Overview
:nodoc:
Instance Method Summary collapse
- #handle_channel_command(identifier, command, data) ⇒ Object
- #initialize(socket, subscriptions: nil, **hargs) ⇒ Object
- #request ⇒ Object
Instance Method Details
#handle_channel_command(identifier, command, data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lite_cable/anycable.rb', line 32 def handle_channel_command(identifier, command, data) channel = subscriptions.add(identifier, false) case command when "subscribe" !subscriptions.send(:subscribe_channel, channel).nil? when "unsubscribe" subscriptions.remove(identifier) true when "message" subscriptions.perform_action identifier, data true else false end rescue LiteCable::Connection::Subscriptions::Error, LiteCable::Channel::Error, LiteCable::Channel::Registry::Error => e log(:error, log_fmt("Connection command failed: #{e}")) close false end |
#initialize(socket, subscriptions: nil, **hargs) ⇒ Object
22 23 24 25 26 |
# File 'lib/lite_cable/anycable.rb', line 22 def initialize(socket, subscriptions: nil, **hargs) super(socket, **hargs) # Initialize channels if any subscriptions&.each { |id| @subscriptions.add(id, false) } end |
#request ⇒ Object
28 29 30 |
# File 'lib/lite_cable/anycable.rb', line 28 def request @request ||= Rack::Request.new(socket.env) end |