Class: Telephony::PusherEventPublisher

Inherits:
Object
  • Object
show all
Defined in:
app/models/telephony/pusher_event_publisher.rb

Class Method Summary collapse

Class Method Details

.publish(event) ⇒ Object



8
9
10
11
12
13
14
15
# File 'app/models/telephony/pusher_event_publisher.rb', line 8

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

.push(event) ⇒ Object



3
4
5
6
# File 'app/models/telephony/pusher_event_publisher.rb', line 3

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

.queue_change(size, event_id, agent = nil) ⇒ Object



17
18
19
20
21
22
23
24
# File 'app/models/telephony/pusher_event_publisher.rb', line 17

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