Sha256: 393c92f114b32fae11838facc13630b83b323afbcaf7353e22d9fbdb890c3f1c

Contents?: true

Size: 642 Bytes

Versions: 2

Compression:

Stored size: 642 Bytes

Contents

module Telephony
  class PusherEventPublisher
    def self.push(event)
      channel, name, data = event.values_at :channel, :name, :data
      Pusher[channel].trigger(name, data)
    end

    def self.publish(event)
      if Telephony::DELAYED_JOB.respond_to?(:enqueue)
        job = Jobs::PusherEvent.new(event)
        DELAYED_JOB.enqueue(job)
      else
        push event
      end
    end

    def self.queue_change(size, event_id, agent=nil)
      publish channel: agent.nil? ? "csrs" : "csrs-#{agent.csr_id}",
        name: 'QueueChange',
        data: {
          size: size,
          event_id: event_id
        }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telephony-1.0.4 app/models/telephony/pusher_event_publisher.rb
telephony-1.0.3 app/models/telephony/pusher_event_publisher.rb