Skip to content

Commit

Permalink
Merge branch 'release/0.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Jan 4, 2016
2 parents a38d260 + fd2aa53 commit 55a9f0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# [develop](https://github.com/adhearsion/electric_slide)

# [0.4.1](https://github.com/adhearsion/electric_slide/compare/v0.4.0...v0.4.1) - [2016-01-04](https://rubygems.org/gems/adhearsion/versions/0.4.1)
* Bugfix: Don't hand out internal CallQueue references to Agents - thread-safety

# [0.4.0](https://github.com/adhearsion/electric_slide/compare/v0.3.0...v0.4.0) - [2015-12-17](https://rubygems.org/gems/adhearsion/versions/0.4.0)
* Change `ElectricSlide::Agent` `#presence=` method name to `#update_presence`. It will also accept one more parameter called `extra_params`, a hash that holds application specific parameters that are passed to the presence change callback.
* `ElectricSlide::CallQueue#add_agent` will no longer wait for a connection attempt to complete before returning
Expand Down
25 changes: 14 additions & 11 deletions lib/electric_slide/call_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def add_agent(agent)
abort ArgumentError.new("#add_agent called with nil object") if agent.nil?
abort DuplicateAgentError.new("Agent is already in the queue") if get_agent(agent.id)

agent.queue = self
agent.queue = current_actor

case @connection_type
when :call
Expand All @@ -177,7 +177,7 @@ def add_agent(agent)
@agents << agent
@strategy << agent if agent.presence == :available
# Fake the presence callback since this is a new agent
agent.callback :presence_change, self, agent.call, agent.presence, :unavailable
agent.callback :presence_change, current_actor, agent.call, agent.presence, :unavailable

async.check_for_connections
end
Expand Down Expand Up @@ -304,7 +304,7 @@ def connect(agent, queued_call)
ignoring_ended_calls do
if agent.call && agent.call.active?
logger.warn "Dead call exception in #connect but agent call still alive, reinserting into queue"
agent.callback :connection_failed, self, agent.call, queued_call
agent.callback :connection_failed, current_actor, agent.call, queued_call

return_agent agent
end
Expand Down Expand Up @@ -367,8 +367,10 @@ def call_agent(agent, queued_call)
# Stash the caller ID so we don't have to try to get it from a dead call object later
queued_caller_id = remote_party queued_call

queue = current_actor

# The call controller is actually run by #dial, here we skip joining if we do not have one
dial_options = agent.dial_options_for(self, queued_call)
dial_options = agent.dial_options_for(queue, queued_call)
unless dial_options[:confirm]
agent_call.on_answer { ignoring_ended_calls { agent_call.join queued_call.uri if queued_call.active? } }
end
Expand All @@ -394,12 +396,12 @@ def call_agent(agent, queued_call)

agent.call = nil

agent.callback :disconnect, self, agent_call, queued_call
agent.callback :disconnect, queue, agent_call, queued_call

unless connected
if queued_call.active?
ignoring_ended_calls { priority_enqueue queued_call }
agent.callback :connection_failed, self, agent_call, queued_call
agent.callback :connection_failed, queue, agent_call, queued_call

logger.warn "Call did not connect to agent! Agent #{agent.id} call ended with #{end_event.reason}; reinserting caller #{queued_caller_id} into queue"
else
Expand All @@ -408,7 +410,7 @@ def call_agent(agent, queued_call)
end
end

agent.callback :connect, self, agent_call, queued_call
agent.callback :connect, queue, agent_call, queued_call

agent_call.execute_controller_or_router_on_answer dial_options.delete(:confirm), dial_options.delete(:confirm_metadata)

Expand All @@ -420,8 +422,9 @@ def bridge_agent(agent, queued_call)
queued_caller_id = remote_party queued_call
agent.call[:queued_call] = queued_call

queue = current_actor
agent.call.register_tmp_handler :event, Punchblock::Event::Unjoined do
agent.callback :disconnect, self, agent.call, queued_call
agent.callback :disconnect, queue, agent.call, queued_call
ignoring_ended_calls { queued_call.hangup }
ignoring_ended_calls { conditionally_return_agent agent if agent.call && agent.call.active? }
agent.call[:queued_call] = nil if agent.call
Expand All @@ -431,13 +434,13 @@ def bridge_agent(agent, queued_call)
queued_call[:electric_slide_connected_at] = event.timestamp
end

agent.callback :connect, self, agent.call, queued_call
agent.callback :connect, current_actor, agent.call, queued_call

agent.join queued_call if queued_call.active?
rescue *ENDED_CALL_EXCEPTIONS
ignoring_ended_calls do
if agent.call && agent.call.active?
agent.callback :connection_failed, self, agent.call, queued_call
agent.callback :connection_failed, current_actor, agent.call, queued_call

logger.info "Caller #{queued_caller_id} failed to connect to Agent #{agent.id} due to caller hangup"
conditionally_return_agent agent, :auto
Expand All @@ -458,7 +461,7 @@ def bridged_agent_health_check(agent)
abort ArgumentError.new("Agent has no active call") unless agent.call && agent.call.active?
unless agent.call[:electric_slide_callback_set]
agent.call[:electric_slide_callback_set] = true
queue = self
queue = current_actor
agent.call.on_end do
agent.call = nil
queue.return_agent agent, :unavailable
Expand Down
2 changes: 1 addition & 1 deletion lib/electric_slide/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
class ElectricSlide
VERSION = '0.4.0'
VERSION = '0.4.1'
end

0 comments on commit 55a9f0f

Please sign in to comment.