class Faye::Channel::Set

Public Instance Methods

distribute_message(message) click to toggle source
# File lib/faye/protocol/channel.rb, line 113
def distribute_message(message)
  channels = Channel.expand(message['channel'])
  channels.each do |name|
    channel = @channels[name]
    channel.trigger(:message, message) if channel
  end
end
has_subscription?(name) click to toggle source
# File lib/faye/protocol/channel.rb, line 90
def has_subscription?(name)
  @channels.has_key?(name)
end
keys() click to toggle source
# File lib/faye/protocol/channel.rb, line 82
def keys
  @channels.keys
end
remove(name) click to toggle source
# File lib/faye/protocol/channel.rb, line 86
def remove(name)
  @channels.delete(name)
end
subscribe(names, subscription) click to toggle source
# File lib/faye/protocol/channel.rb, line 94
def subscribe(names, subscription)
  names.each do |name|
    channel = @channels[name] ||= Channel.new(name)
    channel.bind(:message, &subscription)
  end
end
unsubscribe(name, subscription) click to toggle source
# File lib/faye/protocol/channel.rb, line 101
def unsubscribe(name, subscription)
  channel = @channels[name]
  return false unless channel
  channel.unbind(:message, &subscription)
  if channel.unused?
    remove(name)
    true
  else
    false
  end
end

Public Class Methods

new() click to toggle source
# File lib/faye/protocol/channel.rb, line 78
def initialize
  @channels = {}
end