diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-07-07 21:30:51 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-07-07 21:30:51 +0200 |
commit | 6f4e9dea93ce306ea1badb839a723c2f4de91ccd (patch) | |
tree | 054d540ef283c37fce4e9512c0b3d8fd13cf8bcb /lib | |
parent | 35ffec2c489bead9cc7f9c0525e9c63dc04e3038 (diff) | |
download | rails-6f4e9dea93ce306ea1badb839a723c2f4de91ccd.tar.gz rails-6f4e9dea93ce306ea1badb839a723c2f4de91ccd.tar.bz2 rails-6f4e9dea93ce306ea1badb839a723c2f4de91ccd.zip |
No need for this delegator
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_cable/channel/base.rb | 16 | ||||
-rw-r--r-- | lib/action_cable/channel/streams.rb | 4 |
2 files changed, 8 insertions, 12 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 2fcc82d039..f5d7011a72 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -59,9 +59,11 @@ module ActionCable end end + # Called by the cable connection when its cut so the channel has a chance to cleanup with callbacks. + # This method is not intended to be called directly by the user. Instead, overwrite the #unsubscribed callback. def unsubscribe_from_channel run_unsubscribe_callbacks - logger.info "#{channel_name} unsubscribed" + logger.info "#{self.class.name} unsubscribed" end @@ -77,24 +79,18 @@ module ActionCable def unsubscribed # Override in subclasses end - # Transmit a hash of data to the subscriber. The hash will automatically be wrapped in a JSON envelope with # the proper channel identifier marked as the recipient. def transmit(data, via: nil) - logger.info "#{channel_name} transmitting #{data.inspect}".tap { |m| m << " (via #{via})" if via } + logger.info "#{self.class.name} transmitting #{data.inspect}".tap { |m| m << " (via #{via})" if via } connection.transmit({ identifier: @identifier, message: data }.to_json) end - def channel_name - self.class.name - end - - private def subscribe_to_channel - logger.info "#{channel_name} subscribing" + logger.info "#{self.class.name} subscribing" run_subscribe_callbacks end @@ -107,7 +103,7 @@ module ActionCable end def action_signature(action, data) - "#{channel_name}##{action}".tap do |signature| + "#{self.class.name}##{action}".tap do |signature| if (arguments = data.except('action')).any? signature << "(#{arguments.inspect})" end diff --git a/lib/action_cable/channel/streams.rb b/lib/action_cable/channel/streams.rb index 3eac776e61..9ff2f85fa1 100644 --- a/lib/action_cable/channel/streams.rb +++ b/lib/action_cable/channel/streams.rb @@ -13,13 +13,13 @@ module ActionCable streams << [ broadcasting, callback ] pubsub.subscribe broadcasting, &callback - logger.info "#{channel_name} is streaming from #{broadcasting}" + logger.info "#{self.class.name} is streaming from #{broadcasting}" end def stop_all_streams streams.each do |broadcasting, callback| pubsub.unsubscribe_proc broadcasting, callback - logger.info "#{channel_name} stopped streaming from #{broadcasting}" + logger.info "#{self.class.name} stopped streaming from #{broadcasting}" end end |