class Garufa::API::EventHandler

Public Instance Methods

handle(body) click to toggle source
# File lib/garufa/api/event_handler.rb, line 10
def handle(body)
  notify JSON.parse(body)
end
handle_legacy(body, channel, params) click to toggle source
# File lib/garufa/api/event_handler.rb, line 14
def handle_legacy(body, channel, params)
  notify params.merge(channels: [channel], data: JSON.parse(body))
end

Private Instance Methods

notify(params) click to toggle source
# File lib/garufa/api/event_handler.rb, line 20
def notify(params)
  message = Garufa::Message.new(params)
  options = { data: message.data, socket_id: message.socket_id }

  # Notify event deferred in order to response immediately.
  EM.defer { Garufa::Subscriptions.notify message.channels, message.name, options }
end