class Faye::Channel::Set

Public Class Methods

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

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['data']) 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, callback) click to toggle source
# File lib/faye/protocol/channel.rb, line 94
def subscribe(names, callback)
  names.each do |name|
    channel = @channels[name] ||= Channel.new(name)
    channel.bind(:message, &callback) if callback
  end
end
unsubscribe(name, callback) click to toggle source
# File lib/faye/protocol/channel.rb, line 101
def unsubscribe(name, callback)
  channel = @channels[name]
  return false unless channel
  channel.unbind(:message, &callback)
  if channel.unused?
    remove(name)
    true
  else
    false
  end
end