Method: ActionCable::SubscriptionAdapter::SubscriberMap#add_subscriber

Defined in:
actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb

#add_subscriber(channel, subscriber, on_success) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb', line 11

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