module Loco::Emitter

Public Instance Methods

add_hub(name, members = []) click to toggle source
# File lib/loco/emitter.rb, line 18
def add_hub(name, members = [])
  Hub.set(name, members)
end
del_hub(name) click to toggle source
# File lib/loco/emitter.rb, line 26
def del_hub(name)
  hub = Hub.get(name)
  return false if hub.nil?

  hub.destroy
end
emit(obj, event = nil, opts = {}) click to toggle source
# File lib/loco/emitter.rb, line 5
def emit(obj, event = nil, opts = {})
  Broadcaster.(
    obj,
    event,
    payload: opts[:payload] || opts[:data],
    recipients: opts[opts[:for] ? :for : :to]
  )
end
emit_to(recipient_s, data) click to toggle source
# File lib/loco/emitter.rb, line 14
def emit_to(recipient_s, data)
  Sender.(recipient_s, data)
end
get_hub(name) click to toggle source
# File lib/loco/emitter.rb, line 22
def get_hub(name)
  Hub.get(name)
end