Permalink
Browse files

003_can_retrieve_channel_data.feature is complete skeletal wise. All …

…9192 does is return channel information.

Exposed event info, and content hash keys. content contains the channel data. event is a wrap around content in order to provide headers hash.
hash contains length and type. event.content hash keys are exposed. Looks to caller_id_unique_id, unique_id, caller_channel_name, caller_dialplan, variable_current_application, variable_current_application_data, channel_state, channel_state_number, channel_name.
  • Loading branch information...
Deryl R. Doucette
Deryl R. Doucette committed Feb 11, 2012
1 parent f410159 commit b1fa83268d1642c91f9aba0a4fe276b704f5136a
@@ -7,5 +7,4 @@ Feature: Can receive channel event data of current call
Scenario:
When I dial extension "9192" on tigershark.rubyists.com
Then I should be connected to that extension
- And I should be able to access event data
And I should be able to access channel data
@@ -0,0 +1,66 @@
+require "fsr"
+require "fsr/listener/inbound"
+require "fsr/command_socket"
+FSR.load_all_commands
+class ChanListener < FSL::Inbound
+ # Commented out PLAYBACK_FILES because its already defined higher
+ CHAN_STATE= {}
+
+ def initialize(sock1, sock2, server1, server2, known_extension)
+ @sock1, @sock2, @server1, @server2 = sock1, sock2, server1, server2
+ @number_to_call = known_extension # This is populated from Step, passed in When I dial extension "9192"
+ super()
+ end
+
+ def before_session
+ # subscribe to events
+ add_event(:ALL){|event| handle_event(event) }
+ end
+
+ def post_init
+ @spec_id = rand(100000000).to_s
+ orig = @sock1.originate(target_options: {origination_caller_id_number: @spec_id}, target: "sofia/external/#{@number_to_call}@#{@server2}", endpoint: '&park')
+ @uuid = orig.run(:api)['body'].split[1]
+ warn "UUID is #{@uuid}"
+ warn "spec_id is #{@spec_id}"
+ end
+
+ def handle_event(event)
+ #p event.content[:caller_caller_id_number]
+ return unless (event.content[:caller_caller_id_number] == @spec_id)
+ puts "EVENT DATA - contents of event"
+ puts "event.content class = #{event.content.class} (contents displayed after headers)"
+ puts "event.headers class = #{event.headers.class}"
+ puts "event.headers content = #{event.headers}"
+ puts "event.headers.keys = #{event.headers.keys}"
+ puts "=============="
+ puts "CHANNEL DATA - (For this specific event) - contents of event.content hash\n"
+ printf("event.content.keys = #{event.content.keys.to_s}")
+ puts "=============="
+ # We call it logged in (or unsuccessful) when we hear any of these wavs
+ #if(path == @expected_sound)
+ # And hang up the call
+ @sock1.kill(@uuid).run
+ # Then stop the reactor
+ EM.stop
+ #end
+
+ end
+
+ def unbind
+ end
+end
+
+if __FILE__ == $0
+ @server1 = 'blackbird.rubyists.com'
+ @server2 = 'tigershark.rubyists.com'
+ @sock1 = FSR::CommandSocket.new(server: @server1)
+ @sock2 = FSR::CommandSocket.new(server: @server2)
+ warn "Starting ChanListener, someone better check the IVR quick!"
+ EM.run do
+ EM.add_periodic_timer(20) { |e| EM.stop }
+ # When I press 5, I expect 'screaming monkeys' or what-not
+ EM.connect(@server2, 8021, ChanListener, @sock1, @sock2, @server1, @server2, "4", ChanListener::SOUNDS[:ivr_cluecon])
+ end
+ p ChanListener::PLAYBACK_FILES
+end
@@ -159,10 +159,10 @@
@key_sequence = key_sequence or fail "We got no key_sequence for generating DTMF presses with!"
end
-Then /^I should be able to access event data$/ do
- pending # express the regexp above with the code you wish you had
-end
-
Then /^I should be able to access channel data$/ do
- pending # express the regexp above with the code you wish you had
+ EM.run do
+ # Wait 60 seconds
+ EM.add_periodic_timer(60) { |e| EM.stop }
+ EM.connect(@server2, 8021, ChanListener, @sock1, @sock2, @server1, @server2, known_extension = "9192")
+ end
end

0 comments on commit b1fa832

Please sign in to comment.