Navigation Menu

Skip to content

Commit

Permalink
Piston updated connfu.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroos committed Aug 26, 2011
1 parent 092d39d commit 55434b6
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 140 deletions.
2 changes: 1 addition & 1 deletion vendor/gems/connfu/.piston.yml
Expand Up @@ -4,5 +4,5 @@ lock: false
repository_class: Piston::Git::Repository
format: 1
handler:
commit: 05a15b2d7445b0c95fccbae0b72271a71ba87c2d
commit: 28fc3cd9a15dd305fcbce240fbd6187d985e4166
branch: master
13 changes: 0 additions & 13 deletions vendor/gems/connfu/examples/transfer_using_join.rb

This file was deleted.

13 changes: 0 additions & 13 deletions vendor/gems/connfu/lib/connfu/dsl/call_commands.rb
Expand Up @@ -74,19 +74,6 @@ def dial_join(dial_options)

joined_call_id
end

def transfer_using_join(dial_from, dial_to)
command_options = {
:call_jid => call_jid,
:client_jid => client_jid,
:dial_to => dial_to,
:dial_from => dial_from,
:call_id => call_id
}
send_command Connfu::Commands::NestedJoin.new(command_options)
wait_for Connfu::Event::Hangup
finish!
end
end
end
end
15 changes: 0 additions & 15 deletions vendor/gems/connfu/spec/connfu/dsl_spec.rb
Expand Up @@ -203,21 +203,6 @@ class DslTest
end
end

describe "transfer using join" do
it 'should send NestedJoin command to connection' do
dial_to = 'sip:dial-to@example.com'
dial_from = 'sip:dial-from@example.com'
Connfu.connection.should_receive(:send_command).with(Connfu::Commands::NestedJoin.new(
:dial_to => dial_to,
:dial_from => dial_from,
:client_jid => 'client-jid',
:call_jid => 'call-jid',
:call_id => 'call-id'
))
subject.transfer_using_join(dial_from, dial_to)
end
end

describe 'recording' do
it 'should send a start command to connection' do
subject.stub(:wait_for).and_return(Connfu::Event::Result.new)
Expand Down
2 changes: 1 addition & 1 deletion vendor/gems/connfu/spec/functional/answer_spec.rb
Expand Up @@ -24,6 +24,6 @@
dsl_instance.should_receive(:do_something)

incoming :offer_presence, @call_jid, @client_jid
incoming :result_iq, @call_jid
incoming :answer_result_iq, @call_jid
end
end
5 changes: 4 additions & 1 deletion vendor/gems/connfu/spec/functional/ask_for_digits_spec.rb
Expand Up @@ -4,6 +4,7 @@

testing_dsl do
on :offer do |call|
answer
result = ask(:prompt => "please enter a 4 digit pin", :digits => 4)
say("you entered #{result}")
end
Expand All @@ -16,6 +17,7 @@

it "should send an ask command" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid

last_command.should == Connfu::Commands::Ask.new(
:call_jid => @call_jid,
Expand All @@ -27,7 +29,8 @@

it "should continue when ask was successful" do
incoming :offer_presence, @call_jid, @client_jid
incoming :result_iq, @call_jid
incoming :answer_result_iq, @call_jid
incoming :ask_result_iq, @call_jid
incoming :ask_success_presence, @call_jid, "1234"

last_command.should == Connfu::Commands::Say.new(
Expand Down
3 changes: 1 addition & 2 deletions vendor/gems/connfu/spec/functional/dial_spec.rb
Expand Up @@ -232,7 +232,6 @@ class << self; attr_accessor :stash; end
incoming :dial_result_iq, @call_id, last_command.id
incoming :ringing_presence, @call_jid
incoming :answered_presence, @call_jid
incoming :result_iq, @call_jid

last_command.should be_instance_of Connfu::Commands::Say
last_command.text.should == "hello"
Expand All @@ -242,7 +241,7 @@ class << self; attr_accessor :stash; end
incoming :dial_result_iq, @call_id, last_command.id
incoming :ringing_presence, @call_jid
incoming :answered_presence, @call_jid
incoming :result_iq, @call_jid
incoming :say_result_iq, @call_jid
incoming :say_success_presence, @call_jid

last_command.should be_instance_of Connfu::Commands::Say
Expand Down
12 changes: 6 additions & 6 deletions vendor/gems/connfu/spec/functional/hangup_spec.rb
Expand Up @@ -41,8 +41,8 @@

it "should not send any commands after the hangup" do
incoming :offer_presence, @call_jid, @client_jid
incoming :result_iq, @call_jid # from the answer command
incoming :result_iq, @call_jid # from the hangup command
incoming :answer_result_iq, @call_jid
incoming :hangup_result_iq, @call_jid
incoming :hangup_presence, @call_jid

last_command.should == Connfu::Commands::Hangup.new(:call_jid => @call_jid, :client_jid => @client_jid)
Expand Down Expand Up @@ -70,11 +70,11 @@

it "should still send commands once the other call is hung up" do
incoming :offer_presence, @call_jid, @client_jid
incoming :result_iq, @call_jid # from the answer command
incoming :answer_result_iq, @call_jid
incoming :dial_result_iq, @other_call_id, last_command.id # from the dial command
incoming :ringing_presence, @other_call_jid
incoming :answered_presence, @other_call_jid
incoming :result_iq, @other_call_jid # from the hangup command
incoming :hangup_result_iq, @other_call_jid
incoming :hangup_presence, @other_call_jid

last_command.should == Connfu::Commands::Say.new(:text => "Phew, glad he's gone", :call_jid => @call_jid, :client_jid => @client_jid)
Expand All @@ -96,8 +96,8 @@

it "should not send an implicit hangup command" do
incoming :offer_presence, @call_jid, @client_jid
incoming :result_iq, @call_jid # from the answer command
incoming :result_iq, @call_jid # from the say command
incoming :answer_result_iq, @call_jid
incoming :say_result_iq, @call_jid # from the say command
incoming :hangup_presence, @call_jid # via the user hanging up
incoming :say_success_presence, @call_jid

Expand Down
18 changes: 12 additions & 6 deletions vendor/gems/connfu/spec/functional/offer_spec.rb
Expand Up @@ -9,6 +9,11 @@
)
end
end

before :each do
@call_jid = "call-id@server.whatever"
@client_jid = "usera@127.0.0.whatever/voxeo"
end

it "exposes who the call is from" do
dsl_instance.should_receive(:do_something_with).with(
Expand Down Expand Up @@ -70,13 +75,14 @@
@client_jid = "usera@127.0.0.whatever/voxeo"
end

it "should not issue another hangup after it has been called in the DSL" do
handler_instance = Connfu.event_processor.handler_class.new({})
Connfu.event_processor.stub(:build_handler).and_return(handler_instance)
it "should not issue the automatic hangup after it's been explicitly called in the DSL" do
incoming :offer_presence, @call_jid, @client_jid
incoming :result_iq, @call_jid # from the answer command
handler_instance.should_receive(:hangup).never
incoming :result_iq, @call_jid # from the hangup within DSL
incoming :answer_result_iq, @call_jid
incoming :hangup_result_iq, @call_jid
incoming :hangup_presence, @call_jid

Connfu.connection.commands.length.should == 2
hangup_commands = Connfu.connection.commands.select { |command| command.is_a?(Connfu::Commands::Hangup) }
hangup_commands.length.should == 1
end
end
14 changes: 12 additions & 2 deletions vendor/gems/connfu/spec/functional/record_call_spec.rb
Expand Up @@ -14,6 +14,7 @@

testing_dsl do
on :offer do |call|
answer
start_recording
stop_recording
do_something(recordings)
Expand All @@ -23,12 +24,14 @@

it "should send first record start command" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid

last_command.should == Connfu::Commands::Recording::Start.new(:call_jid => @call_jid, :client_jid => @client_jid)
end

it "should send the stop recording command with the recording ID when start recording has been sent" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :recording_result_iq, @call_jid, @recording_component_id

last_command.should == Connfu::Commands::Recording::Stop.new(:call_jid => @call_jid, :client_jid => @client_jid, :component_id => @recording_component_id)
Expand All @@ -38,17 +41,19 @@
dsl_instance.should_receive(:do_something).with([@recording_path])

incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :recording_result_iq, @call_jid, @recording_component_id
incoming :result_iq, @call_jid
incoming :recording_stop_result_iq, @call_jid, @recording_component_id
incoming :recording_stop_presence, @component_jid, @recording_path
end

it "should hangup once we know the recording was complete" do
dsl_instance.stub(:do_something)

incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :recording_result_iq, @call_jid, @recording_component_id
incoming :result_iq, @call_jid
incoming :recording_stop_result_iq, @call_jid, @recording_component_id
incoming :recording_stop_presence, @component_jid, @recording_path

last_command.should == Connfu::Commands::Hangup.new(:call_jid => @call_jid, :client_jid => @client_jid)
Expand All @@ -58,13 +63,15 @@
describe "when the caller hangs up during recording" do
testing_dsl do
on :offer do |call|
answer
record_for 5
say "very interesting"
end
end

it "should not send any commands after the hangup is detected" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :recording_result_iq, @call_jid, @recording_component_id
incoming :recording_hangup_presence, @component_jid

Expand All @@ -76,6 +83,7 @@

testing_dsl do
on :offer do |call|
answer
record_for 5
do_something(recordings)
end
Expand All @@ -86,6 +94,7 @@
dsl_instance.should_receive(:do_something).with([@recording_path])

incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :recording_result_iq, @call_jid, @recording_component_id
incoming :recording_stop_presence, @component_jid, @recording_path
end
Expand All @@ -96,6 +105,7 @@
dsl_instance.should_receive(:do_something).with([@recording_path])

incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :recording_result_iq, @call_jid, @recording_component_id
incoming :recording_hangup_presence, @component_jid, @recording_path
end
Expand Down
8 changes: 6 additions & 2 deletions vendor/gems/connfu/spec/functional/say_spec.rb
Expand Up @@ -4,6 +4,7 @@

testing_dsl do
on :offer do |call|
answer
say('hello, this is connfu')
say('http://www.phono.com/audio/troporocks.mp3')
end
Expand All @@ -17,19 +18,22 @@

it "should send first say command" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid

last_command.should == Connfu::Commands::Say.new(:text => 'hello, this is connfu', :call_jid => @call_jid, :client_jid => @client_jid)
end

it "should not send the second say command if the first command's success hasn't been received" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :say_result_iq, @call_jid

last_command.should == Connfu::Commands::Say.new(:text => 'hello, this is connfu', :call_jid => @call_jid, :client_jid => @client_jid)
end

it "should send the second say command once the first say command has completed" do
incoming :offer_presence, @call_jid, @client_jid
incoming :answer_result_iq, @call_jid
incoming :say_result_iq, @call_jid
incoming :say_success_presence, @call_jid

Expand All @@ -52,7 +56,7 @@

it 'should send the stop command to an active say component' do
incoming :offer_presence, call_jid
incoming :result_iq, call_jid, last_command.id
incoming :answer_result_iq, call_jid, last_command.id
incoming :say_result_iq, call_jid
incoming :dial_result_iq, "dummy-call-so-we-can-wait-id", last_command.id

Expand All @@ -61,7 +65,7 @@

it 'should not send the stop command if the say component has already finished' do
incoming :offer_presence, call_jid
incoming :result_iq, call_jid, last_command.id
incoming :answer_result_iq, call_jid, last_command.id
incoming :say_result_iq, call_jid, 'component-id'
incoming :say_success_presence, "#{call_jid}/component-id"
incoming :dial_result_iq, "dummy-call-so-we-can-wait-id", last_command.id
Expand Down

0 comments on commit 55434b6

Please sign in to comment.