Method: Redis::Distributed#subscribe

Defined in:
lib/redis/distributed.rb

#subscribe(channel, *channels, &block) ⇒ Object

Listen for messages published to the given channels.



931
932
933
934
935
936
937
938
939
940
941
# File 'lib/redis/distributed.rb', line 931

def subscribe(channel, *channels, &block)
  if channels.empty?
    @subscribed_node = node_for(channel)
    @subscribed_node.subscribe(channel, &block)
  else
    ensure_same_node(:subscribe, [channel] + channels) do |node|
      @subscribed_node = node
      node.subscribe(channel, *channels, &block)
    end
  end
end