aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/channel/streams.rb
diff options
context:
space:
mode:
authorNick Quaranto <nick@quaran.to>2016-02-02 11:16:41 -0500
committerNick Quaranto <nick@quaran.to>2016-02-02 15:00:05 -0500
commit830543738507f49444956b3b6ae897f4638b2523 (patch)
tree5f6eaf8b78d1fcdc0d6b29a949bbfc1d4445b2c2 /actioncable/lib/action_cable/channel/streams.rb
parent473f63734a55d2a91083a619ce1395dfe32aec8d (diff)
downloadrails-830543738507f49444956b3b6ae897f4638b2523.tar.gz
rails-830543738507f49444956b3b6ae897f4638b2523.tar.bz2
rails-830543738507f49444956b3b6ae897f4638b2523.zip
[ci skip] Several ActionCable documentation updates:
* Properly indent code sample in ActionCable::Channel::Streams * Add a doc comment for #stop_all_streams * Reformat + add <tt> blocks around code references in ActionCable::Base docs * Clarify and a little better grammar on ActionCable::RemoteConnections * Correct indentation and clean up ActionCable::Server::Broadcasting code sample
Diffstat (limited to 'actioncable/lib/action_cable/channel/streams.rb')
-rw-r--r--actioncable/lib/action_cable/channel/streams.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/actioncable/lib/action_cable/channel/streams.rb b/actioncable/lib/action_cable/channel/streams.rb
index a26373e387..3158f30814 100644
--- a/actioncable/lib/action_cable/channel/streams.rb
+++ b/actioncable/lib/action_cable/channel/streams.rb
@@ -41,22 +41,23 @@ module ActionCable
# Example below shows how you can use this to provide performance introspection in the process:
#
# class ChatChannel < ApplicationCable::Channel
- # def subscribed
- # @room = Chat::Room[params[:room_number]]
+ # def subscribed
+ # @room = Chat::Room[params[:room_number]]
#
- # stream_for @room, -> (encoded_message) do
- # message = ActiveSupport::JSON.decode(encoded_message)
+ # stream_for @room, -> (encoded_message) do
+ # message = ActiveSupport::JSON.decode(encoded_message)
#
- # if message['originated_at'].present?
- # elapsed_time = (Time.now.to_f - message['originated_at']).round(2)
+ # if message['originated_at'].present?
+ # elapsed_time = (Time.now.to_f - message['originated_at']).round(2)
#
- # ActiveSupport::Notifications.instrument :performance, measurement: 'Chat.message_delay', value: elapsed_time, action: :timing
- # logger.info "Message took #{elapsed_time}s to arrive"
- # end
+ # ActiveSupport::Notifications.instrument :performance, measurement: 'Chat.message_delay', value: elapsed_time, action: :timing
+ # logger.info "Message took #{elapsed_time}s to arrive"
+ # end
#
- # transmit message
- # end
- # end
+ # transmit message
+ # end
+ # end
+ # end
#
# You can stop streaming from all broadcasts by calling #stop_all_streams.
module Streams
@@ -90,6 +91,7 @@ module ActionCable
stream_from(broadcasting_for([ channel_name, model ]), callback)
end
+ # Unsubscribes all streams associated with this channel from the pubsub queue.
def stop_all_streams
streams.each do |broadcasting, callback|
pubsub.unsubscribe broadcasting, callback