Question about Adhearsion::CallController.execute_component_and_await_completion

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about Adhearsion::CallController.execute_component_and_await_completion

Giorgio Bianchi
This is the code : 

def execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  component
end

I've found a strange behavior : if I execute a command (E.G. play a file, ask a digit, etc) and the caller hangup during the command, the code written after the command in the controller will be executed

class Test < Adhearsion::CallController

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    hangup
  end

end

Is that a feature or a bug? To prevent this the code should be :


def
execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  raise Adhearsion::Call::Hangup if complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
  component
end

Is there a reason to not patch the CallController code like this?

Thanks for your support.

Giorgio

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about Adhearsion::CallController.execute_component_and_await_completion

Ben Langfeld-2
You absolutely could do this. PRs to that effect are welcome.
Em seg, 5 de dez de 2016 às 08:29, Giorgio Bianchi <[hidden email]> escreveu:
This is the code : 

def execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  component
end

I've found a strange behavior : if I execute a command (E.G. play a file, ask a digit, etc) and the caller hangup during the command, the code written after the command in the controller will be executed

class Test < Adhearsion::CallController

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    hangup
  end

end

Is that a feature or a bug? To prevent this the code should be :


def
execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  raise Adhearsion::Call::Hangup if complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
  component
end

Is there a reason to not patch the CallController code like this?

Thanks for your support.

Giorgio

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about Adhearsion::CallController.execute_component_and_await_completion

Giorgio Bianchi
Hi Ben, thanks for your reply!

To solve all the concernig problems, this should be the full solution to apply to the extended CallController class : 

class Test < Adhearsion::CallController
  def initialize(call, metadata = nil, &block)
   
@call_hangup_flag = false
    call.register_event_handler Punchblock::Event::Complete do |event|
     
if event.reason.is_a? Punchblock::Event::Complete::Hangup
        @call_hangup_flag = true
      end
    end
    super
  end

  def is_current_call_terminatig?
    @call_hangup_flag || !call.active?
 
end

  def execute_component_and_await_completion(component)
   
super
    if component.complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
      hangup
   
end
    component
  end

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    record_result = record interruptible: true, max_duration: 30.seconds, initial_timeout: 5, final_timeout: 5
    if !is_current_call_terminatig?
      logger
.info "Should not print me on call hangup during record"
    end
  end

end

Without "is_current_call_terminating?" method, you won't be able to not print the logger info after record method call
Based on your experience, can this solution cause any problems or is there a better solution to solve?
Thanks for your support

Giorgio


Il giorno lunedì 5 dicembre 2016 18:45:02 UTC+1, Ben Langfeld ha scritto:
You absolutely could do this. PRs to that effect are welcome.
Em seg, 5 de dez de 2016 às 08:29, Giorgio Bianchi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tXwCgjtnDAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">gggg.b...@...> escreveu:
This is the code : 

def execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  component
end

I've found a strange behavior : if I execute a command (E.G. play a file, ask a digit, etc) and the caller hangup during the command, the code written after the command in the controller will be executed

class Test < Adhearsion::CallController

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    hangup
  end

end

Is that a feature or a bug? To prevent this the code should be :


def
execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  raise Adhearsion::Call::Hangup if complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
  component
end

Is there a reason to not patch the CallController code like this?

Thanks for your support.

Giorgio

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tXwCgjtnDAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">adhearsion+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about Adhearsion::CallController.execute_component_and_await_completion

Ben Langfeld
It would be easier to see the change you're proposing if you were to submit this as a pull request. Could you do that first so we can continue the discussion there?

Enviado do meu iPhone

Em 6 de dez de 2016, às 14:35, Giorgio Bianchi <[hidden email]> escreveu:

Hi Ben, thanks for your reply!

To solve all the concernig problems, this should be the full solution to apply to the extended CallController class : 

class Test < Adhearsion::CallController
  def initialize(call, metadata = nil, &block)
   
@call_hangup_flag = false
    call.register_event_handler Punchblock::Event::Complete do |event|
     
if event.reason.is_a? Punchblock::Event::Complete::Hangup
        @call_hangup_flag = true
      end
    end
    super
  end

  def is_current_call_terminatig?
    @call_hangup_flag || !call.active?
 
end

  def execute_component_and_await_completion(component)
   
super
    if component.complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
      hangup
   
end
    component
  end

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    record_result = record interruptible: true, max_duration: 30.seconds, initial_timeout: 5, final_timeout: 5
    if !is_current_call_terminatig?
      logger
.info "Should not print me on call hangup during record"
    end
  end

end

Without "is_current_call_terminating?" method, you won't be able to not print the logger info after record method call
Based on your experience, can this solution cause any problems or is there a better solution to solve?
Thanks for your support

Giorgio


Il giorno lunedì 5 dicembre 2016 18:45:02 UTC+1, Ben Langfeld ha scritto:
You absolutely could do this. PRs to that effect are welcome.
Em seg, 5 de dez de 2016 às 08:29, Giorgio Bianchi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tXwCgjtnDAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">gggg.b...@...> escreveu:
This is the code : 

def execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  component
end

I've found a strange behavior : if I execute a command (E.G. play a file, ask a digit, etc) and the caller hangup during the command, the code written after the command in the controller will be executed

class Test < Adhearsion::CallController

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    hangup
  end

end

Is that a feature or a bug? To prevent this the code should be :


def
execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  raise Adhearsion::Call::Hangup if complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
  component
end

Is there a reason to not patch the CallController code like this?

Thanks for your support.

Giorgio

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tXwCgjtnDAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">adhearsion+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Question about Adhearsion::CallController.execute_component_and_await_completion

Giorgio Bianchi
Hi Ben,

https://github.com/adhearsion/adhearsion/pull/614

I ran "rake rspec" on gem with success (I had to disable some development dependencies, without committing this change, to be able to bundle install)

#s.add_development_dependency 'aruba', "~> 0.5"
#s.add_development_dependency 'ci_reporter_rspec'
#s.add_development_dependency 'ci_reporter_cucumber'
#s.add_development_dependency 'cucumber'
#s.add_development_dependency 'guard-cucumber'
#s.add_development_dependency 'guard-rspec'
s.add_development_dependency 'rspec', ["~> 3.0"]
#s.add_development_dependency 'simplecov'
#s.add_development_dependency 'simplecov-rcov'
#s.add_development_dependency 'yard'
#s.add_development_dependency 'guard-yard'
s.add_development_dependency 'coveralls'
s.add_development_dependency 'timecop'

Thanks for your support

Giorgio

Il giorno martedì 6 dicembre 2016 21:10:16 UTC+1, Ben Langfeld ha scritto:
It would be easier to see the change you're proposing if you were to submit this as a pull request. Could you do that first so we can continue the discussion there?

Enviado do meu iPhone

Em 6 de dez de 2016, às 14:35, Giorgio Bianchi <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="jy9M2ry9DAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">gggg.b...@...> escreveu:

Hi Ben, thanks for your reply!

To solve all the concernig problems, this should be the full solution to apply to the extended CallController class : 

class Test < Adhearsion::CallController
  def initialize(call, metadata = nil, &block)
   
@call_hangup_flag = false
    call.register_event_handler Punchblock::Event::Complete do |event|
     
if event.reason.is_a? Punchblock::Event::Complete::Hangup
        @call_hangup_flag = true
      end
    end
    super
  end

  def is_current_call_terminatig?
    @call_hangup_flag || !call.active?
 
end

  def execute_component_and_await_completion(component)
   
super
    if component.complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
      hangup
   
end
    component
  end

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    record_result = record interruptible: true, max_duration: 30.seconds, initial_timeout: 5, final_timeout: 5
    if !is_current_call_terminatig?
      logger
.info "Should not print me on call hangup during record"
    end
  end

end

Without "is_current_call_terminating?" method, you won't be able to not print the logger info after record method call
Based on your experience, can this solution cause any problems or is there a better solution to solve?
Thanks for your support

Giorgio


Il giorno lunedì 5 dicembre 2016 18:45:02 UTC+1, Ben Langfeld ha scritto:
You absolutely could do this. PRs to that effect are welcome.
Em seg, 5 de dez de 2016 às 08:29, Giorgio Bianchi <[hidden email]> escreveu:
This is the code : 

def execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  component
end

I've found a strange behavior : if I execute a command (E.G. play a file, ask a digit, etc) and the caller hangup during the command, the code written after the command in the controller will be executed

class Test < Adhearsion::CallController

  def run
    answer
    play
"test.wav"
    logger.info "Should not print me on call hangup during play of test.wav"
    hangup
  end

end

Is that a feature or a bug? To prevent this the code should be :


def
execute_component_and_await_completion(component)
  write_and_await_response
component

  yield component if block_given?

 
complete_event = component.complete_event
 
raise Adhearsion::Error, [complete_event.reason.details, component.inspect].join(": ") if complete_event.reason.is_a? Punchblock::Event::Complete::Error
  raise Adhearsion::Call::Hangup if complete_event.reason.is_a? Punchblock::Event::Complete::Hangup
  component
end

Is there a reason to not patch the CallController code like this?

Thanks for your support.

Giorgio

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adhearsion+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jy9M2ry9DAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">adhearsion+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.