Method: Adhearsion::CallController::Dial::Dial#merge

Defined in:
lib/adhearsion/call_controller/dial.rb

#merge(other) ⇒ Object

Merge another Dial into this one, joining all calls to a mixer



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/adhearsion/call_controller/dial.rb', line 280

def merge(other)
  logger.info "Merging with #{other.inspect}"

  split
  other.split

  rejoin({mixer_name: @id}, {})
  other.rejoin({mixer_name: @id}, {})

  calls_to_merge = other.status.calls + [other.root_call]
  @calls.merge calls_to_merge

  latch = CountDownLatch.new calls_to_merge.size
  calls_to_merge.each do |call|
    call.on_end { |event| latch.countdown! }
  end
  @waiters << latch
end