module Qwaiter
  mattr_accessor :event_host
  mattr_accessor :broadcaster
  extend ActiveSupport::Autoload
  autoload :Distribution
  autoload :Serializer
  autoload :UserBaseSerializer
  autoload :SupplierBaseSerializer
  autoload :EmployeeBaseSerializer
  autoload :WaiterBaseSerializer
  autoload :Counter
  autoload :Broadcaster
  autoload :Couchbase
  autoload :DrbCounter

  def self.broadcast_user(uid, event, data)
    message = {channel: "/user/#{uid}", data: {event: event, data: data}}
    broadcaster.broadcast message
  end

  def self.broadcast_supplier(sid, event, data)
    message = {channel: "/supplier/#{sid}", data: {event: event, data: data}}
    broadcaster.broadcast message
  end
end
