diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-06-20 17:45:30 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-06-20 17:45:30 +0200 |
commit | dd77dd3868b6ea9942dc1340cba4491c2f1bc750 (patch) | |
tree | 7416d51224b1dd67bf9899da4b054768cbdce2aa /lib/action_cable/channel/base.rb | |
parent | 7c1becfc1a0ebeb5a1fd840afd89af26b3a6f02d (diff) | |
parent | 082c6317f0b680f4bcd3b1643e6481bed4606139 (diff) | |
download | rails-dd77dd3868b6ea9942dc1340cba4491c2f1bc750.tar.gz rails-dd77dd3868b6ea9942dc1340cba4491c2f1bc750.tar.bz2 rails-dd77dd3868b6ea9942dc1340cba4491c2f1bc750.zip |
Merge branch 'master' of github.com:basecamp/action_cable
Diffstat (limited to 'lib/action_cable/channel/base.rb')
-rw-r--r-- | lib/action_cable/channel/base.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb index 6060ccf681..e6ca45ddcc 100644 --- a/lib/action_cable/channel/base.rb +++ b/lib/action_cable/channel/base.rb @@ -31,6 +31,12 @@ module ActionCable perform_connection end + def perform_connection + logger.info "#{channel_name} connecting" + connect + run_subscribe_callbacks + end + def perform_action(data) if authorized? action = extract_action(data) @@ -52,11 +58,6 @@ module ActionCable logger.info "#{channel_name} disconnected" end - def perform_connection - logger.info "#{channel_name} connecting" - connect - run_subscribe_callbacks - end protected # Override in subclasses @@ -78,10 +79,10 @@ module ActionCable end - def broadcast(data) + def transmit(data, via: nil) if authorized? - logger.info "#{channel_name} broadcasting #{data.inspect}" - connection.broadcast({ identifier: @channel_identifier, message: data }.to_json) + logger.info "#{channel_name} transmitting #{data.inspect}".tap { |m| m << " (via #{via})" if via } + connection.transmit({ identifier: @channel_identifier, message: data }.to_json) else unauthorized end |