方法
- A
- B
- I
- N
- R
类公共方法
new() 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 8 def initialize @subscribers = Hash.new { |h, k| h[k] = [] } @sync = Mutex.new end
实例公共方法
add_channel(channel, on_success) 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 49 def add_channel(channel, on_success) on_success.call if on_success end
add_subscriber(channel, subscriber, on_success) 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 13 def add_subscriber(channel, subscriber, on_success) @sync.synchronize do new_channel = !@subscribers.key?(channel) @subscribers[channel] << subscriber if new_channel add_channel channel, on_success elsif on_success on_success.call end end end
broadcast(channel, message) 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 38 def broadcast(channel, message) list = @sync.synchronize do return if !@subscribers.key?(channel) @subscribers[channel].dup end list.each do |subscriber| invoke_callback(subscriber, message) end end
invoke_callback(callback, message) 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 56 def invoke_callback(callback, message) callback.call message end
remove_channel(channel) 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 53 def remove_channel(channel) end
remove_subscriber(channel, subscriber) 链接
来源: 显示 | 在 GitHub 上
# File actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb, line 27 def remove_subscriber(channel, subscriber) @sync.synchronize do @subscribers[channel].delete(subscriber) if @subscribers[channel].empty? @subscribers.delete channel remove_channel channel end end end