Skip to content

Commit

Permalink
Bridge events should be processed in either channel order
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Aug 10, 2015
1 parent 6474af4 commit eec7e96
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
* Change: Define configuration per-environment for any environment name and without colliding with plugin names. See [#442](https://github.com/adhearsion/adhearsion/issues/442). Syntax is now `config.env(:development).foo = :bar` instead of `config.development.foo = :bar`.
* Feature: Introduce the concept of application specific config. Similar to a plugin, an Application can specify config and an initialiser, and is the place to put such application-wide and unshareable things.
* Bugfix: Calls remain inactive even after they shut down. Previously, to reliably check if a call was up or down it was necessary to consider the case where the call actor had been shut down. This is irrelevant to the `Adhearsion::Call#active?` question, which should *always* return a boolean. It now does.
* Bugfix: Process joined events on Asterisk 13 in any order, avoiding Join command timeout

# [3.0.0.beta1](https://github.com/adhearsion/adhearsion/compare/v2.6.1...v3.0.0.beta1) - [2015-06-24](https://rubygems.org/gems/adhearsion/versions/3.0.0.beta1)
* Change: Removed `Adhearsion.ahn_root=` which was deprecated in favour of `Adhearsion.root=`
Expand Down
3 changes: 2 additions & 1 deletion lib/adhearsion/translator/asterisk/call.rb
Expand Up @@ -139,7 +139,8 @@ def process_ami_event(ami_event)
when 'BridgeEnter'
if other_call_channel = translator.bridges.delete(ami_event['BridgeUniqueid'])
if other_call = translator.call_for_channel(other_call_channel)
join_command = other_call.pending_joins.delete channel
join_command = @pending_joins.delete other_call_channel
join_command ||= other_call.pending_joins.delete channel
join_command.response = true if join_command

event = Adhearsion::Event::Joined.new call_uri: other_call.id, timestamp: ami_event.best_time
Expand Down
45 changes: 45 additions & 0 deletions spec/adhearsion/translator/asterisk/call_spec.rb
Expand Up @@ -864,6 +864,29 @@ def should_use_ami_timestamp_for_rayo_event
translator.handle_ami_event ami_event
expect(command.response(0.5)).to eq(true)
end

context 'out of order' do
let :ami_event do
RubyAMI::Event.new 'BridgeEnter',
'Privilege' => "call,all",
'BridgeUniqueid' => bridge_uniqueid,
'Channel' => other_channel
end

let :second_ami_event do
RubyAMI::Event.new 'BridgeEnter',
'Privilege' => "call,all",
'BridgeUniqueid' => bridge_uniqueid,
'Channel' => call_channel
end

it 'sends the correct Joined events' do
expect(translator).to receive(:handle_pb_event).with expected_joined
expect(translator).to receive(:handle_pb_event).with expected_joined_other
translator.handle_ami_event second_ami_event
expect(command.response(0.5)).to eq(true)
end
end
end
end

Expand Down Expand Up @@ -919,6 +942,28 @@ def should_use_ami_timestamp_for_rayo_event
expect(translator).to receive(:handle_pb_event).with expected_unjoined_other
translator.handle_ami_event second_ami_event
end

context 'out of order' do
let :ami_event do
RubyAMI::Event.new 'BridgeLeave',
'Privilege' => "call,all",
'BridgeUniqueid' => bridge_uniqueid,
'Channel' => other_channel
end

let :second_ami_event do
RubyAMI::Event.new 'BridgeLeave',
'Privilege' => "call,all",
'BridgeUniqueid' => bridge_uniqueid,
'Channel' => call_channel
end

it 'sends the correct Unjoined events' do
expect(translator).to receive(:handle_pb_event).with expected_unjoined
expect(translator).to receive(:handle_pb_event).with expected_unjoined_other
translator.handle_ami_event second_ami_event
end
end
end
end

Expand Down

0 comments on commit eec7e96

Please sign in to comment.