freeswitcher 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +3 -2
- data/CHANGELOG +123 -0
- data/MANIFEST +4 -0
- data/README +6 -6
- data/Rakefile +1 -1
- data/examples/inbound_event_socket.rb +1 -1
- data/examples/outbound_event_socket.rb +6 -2
- data/freeswitcher.gemspec +13 -136
- data/lib/fsr.rb +4 -4
- data/lib/fsr/app/bind_meta_app.rb +26 -0
- data/lib/fsr/app/bridge.rb +6 -5
- data/lib/fsr/app/execute_app.rb +15 -0
- data/lib/fsr/app/play_and_get_digits.rb +24 -9
- data/lib/fsr/app/read.rb +1 -1
- data/lib/fsr/app/speak.rb +2 -1
- data/lib/fsr/cmd/sofia_contact.rb +1 -1
- data/lib/fsr/listener/header_and_content_response.rb +5 -0
- data/lib/fsr/listener/inbound.rb +63 -6
- data/lib/fsr/listener/outbound.rb +8 -1
- data/lib/fsr/version.rb +1 -1
- data/spec/fsr/app/bind_meta_app.rb +18 -0
- data/spec/fsr/app/bridge.rb +38 -7
- data/spec/fsr/app/execute_app.rb +15 -0
- data/spec/fsr/app/play_and_get_digits.rb +41 -2
- data/spec/fsr/listener/header_and_content_response.rb +14 -6
- data/spec/fsr/listener/inbound.rb +22 -8
- data/spec/fsr/listener/outbound.rb +26 -2
- data/spec/fsr/loading.rb +1 -1
- metadata +100 -98
data/AUTHORS
CHANGED
@@ -2,13 +2,14 @@ Following persons have contributed to freeswitcher.
|
|
2
2
|
(Sorted by number of submitted patches, then alphabetically)
|
3
3
|
|
4
4
|
125 TJ Vanderpoel <bougy.man@gmail.com>
|
5
|
-
|
5
|
+
122 Jayson Vaughn <vaughn.jayson@gmail.com>
|
6
6
|
40 Michael Fellinger <m.fellinger@gmail.com>
|
7
|
+
10 Harry Vangberg <harry@vangberg.name>
|
8
|
+
7 TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
7
9
|
6 Mikael Bjerkeland <mikael@consoll.no>
|
8
10
|
4 foo <jvaughn@hellspass.nationwide-recovery.com>
|
9
11
|
3 Kevin Berry <kevin@opensourcealchemist.com>
|
10
12
|
2 freeswitch <freeswitch@falcon.(none)>
|
11
13
|
2 TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
|
12
14
|
1 TJ Vanderpoel <bougyman@zero.(none)>
|
13
|
-
1 TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
14
15
|
1 U-Paul-PC\Paul <Paul@Paul-PC.(none)>
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,126 @@
|
|
1
|
+
[1f5537d | 2009-11-18 06:43:28 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
2
|
+
|
3
|
+
* commented out more debugging
|
4
|
+
|
5
|
+
[4eb4342 | 2009-11-18 06:42:33 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
6
|
+
|
7
|
+
* commented out debugging
|
8
|
+
|
9
|
+
[daa5c02 | 2009-11-18 06:03:59 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
10
|
+
|
11
|
+
* upped version to 0.4.3, encompassing harryv bug fixes
|
12
|
+
|
13
|
+
[3685cad | 2009-11-18 06:01:06 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
14
|
+
|
15
|
+
* removed non-UTF characters from inbound.rb
|
16
|
+
|
17
|
+
[d90ae67 | 2009-11-16 21:09:04 UTC] Harry Vangberg <harry@vangberg.name>
|
18
|
+
|
19
|
+
* reconnect inbound listener when no connection has been made
|
20
|
+
|
21
|
+
[1d41dcb | 2009-11-10 21:16:35 UTC] Harry Vangberg <harry@vangberg.name>
|
22
|
+
|
23
|
+
* signature should be integer to make tests pass
|
24
|
+
|
25
|
+
[313b7cc | 2009-11-10 21:16:03 UTC] Harry Vangberg <harry@vangberg.name>
|
26
|
+
|
27
|
+
* don't force rubygems
|
28
|
+
|
29
|
+
[45bc310 | 2009-09-24 03:42:47 UTC] Harry Vangberg <harry@vangberg.name>
|
30
|
+
|
31
|
+
* inbound socket should default to port 8021
|
32
|
+
|
33
|
+
[1a5c881 | 2009-09-22 21:31:14 UTC] Harry Vangberg <harry@vangberg.name>
|
34
|
+
|
35
|
+
* instance_eval event hooks
|
36
|
+
|
37
|
+
[f5a32b5 | 2009-09-02 19:01:46 UTC] Harry Vangberg <harry@vangberg.name>
|
38
|
+
|
39
|
+
* strip newlines from event.content values
|
40
|
+
|
41
|
+
[206d683 | 2009-09-02 19:48:03 UTC] Harry Vangberg <harry@vangberg.name>
|
42
|
+
|
43
|
+
* rename app -> execute_app. otherwise it royally fucked up.
|
44
|
+
|
45
|
+
[0d16330 | 2009-09-02 17:31:15 UTC] Harry Vangberg <harry@vangberg.name>
|
46
|
+
|
47
|
+
* Add App::App for executing arbitrary apps.
|
48
|
+
|
49
|
+
Use: app("app_name", "arg1", "arg2")
|
50
|
+
|
51
|
+
[911a4db | 2009-08-27 13:50:20 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
52
|
+
|
53
|
+
* Brain fart - changed #push to #unshift. We need the update_session
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
[4ad32cb | 2009-08-27 13:40:04 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
58
|
+
|
59
|
+
* When using an FSR::App object with a FSR::Listener::Outbound instance
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
[17630f1 | 2009-08-25 23:57:07 UTC] Harry Vangberg <harry@vangberg.name>
|
64
|
+
|
65
|
+
* add App::BindMetaApp
|
66
|
+
|
67
|
+
[2867c81 | 2009-08-24 19:03:57 UTC] Harry Vangberg <harry@vangberg.name>
|
68
|
+
|
69
|
+
* take multiple endpoints + :sequential => true
|
70
|
+
|
71
|
+
[b3cd01a | 2009-08-21 18:48:08 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
72
|
+
|
73
|
+
* pushed the lib, too :)
|
74
|
+
|
75
|
+
[9fc86a2 | 2009-08-21 18:17:35 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
76
|
+
|
77
|
+
* added hash accessible arguments to play_and_get_digits
|
78
|
+
|
79
|
+
[6ed562f | 2009-08-20 18:44:28 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
80
|
+
|
81
|
+
* Updated examples to use #to_s incase something goes wrong. I.e. wrong
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
[2a3e3e5 | 2009-08-20 15:34:10 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
86
|
+
|
87
|
+
* Reverted back to not use FSR::App in the inbound listener. Was a
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
[73464df | 2009-08-20 15:25:53 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
92
|
+
|
93
|
+
* Added load_all_applications to inbound event socket as well as include
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
[f50b64d | 2009-08-20 15:22:26 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
98
|
+
|
99
|
+
* Added FSR::Inbound::Listener#api as an abstraction to #say("api blah")
|
100
|
+
|
101
|
+
[ec9cad3 | 2009-08-20 14:44:36 UTC] Jayson Vaughn <jayson@onedrop.(none)>
|
102
|
+
|
103
|
+
* Added callback FSR::Listener::Inbound#before_session that is called once before
|
104
|
+
|
105
|
+
|
106
|
+
Added FSR::Listener::Inbound#add_event and #del_event for instance level
|
107
|
+
event hooks. As opposed to add_event_hook and del_event_hook which are
|
108
|
+
class level
|
109
|
+
|
110
|
+
Added specs for before_session and add_event and del_event
|
111
|
+
|
112
|
+
[63021ac | 2009-07-16 12:55:00 UTC] Jayson Vaughn <jayson@debtorforever.(none)>
|
113
|
+
|
114
|
+
* Probably be good to actually send sched_hangup command to FS in the sched_hangup method
|
115
|
+
|
116
|
+
[763464f | 2009-07-16 12:26:46 UTC] Jayson Vaughn <jayson@debtorforever.(none)>
|
117
|
+
|
118
|
+
* Added FSR::Listener::Outbound#sched_hangup
|
119
|
+
|
120
|
+
[33ab5f7 | 2009-07-15 19:18:01 UTC] Jayson Vaughn <JaysonVaughn@tiger.Nationwide-recovery.com>
|
121
|
+
|
122
|
+
* Added engine capabilities to FSR::App::Speak
|
123
|
+
|
1
124
|
[fc083ef | 2009-07-03 14:14:17 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
|
2
125
|
|
3
126
|
* Version 0.4.2
|
data/MANIFEST
CHANGED
@@ -13,8 +13,10 @@ freeswitcher.gemspec
|
|
13
13
|
lib/fsr.rb
|
14
14
|
lib/fsr/app.rb
|
15
15
|
lib/fsr/app/answer.rb
|
16
|
+
lib/fsr/app/bind_meta_app.rb
|
16
17
|
lib/fsr/app/bridge.rb
|
17
18
|
lib/fsr/app/conference.rb
|
19
|
+
lib/fsr/app/execute_app.rb
|
18
20
|
lib/fsr/app/fifo.rb
|
19
21
|
lib/fsr/app/fs_break.rb
|
20
22
|
lib/fsr/app/fs_sleep.rb
|
@@ -74,8 +76,10 @@ spec/helper.rb
|
|
74
76
|
spec/fsr_listener_helper.rb
|
75
77
|
spec/fsr/app.rb
|
76
78
|
spec/fsr/app/answer.rb
|
79
|
+
spec/fsr/app/bind_meta_app.rb
|
77
80
|
spec/fsr/app/bridge.rb
|
78
81
|
spec/fsr/app/conference.rb
|
82
|
+
spec/fsr/app/execute_app.rb
|
79
83
|
spec/fsr/app/fifo.rb
|
80
84
|
spec/fsr/app/fs_break.rb
|
81
85
|
spec/fsr/app/fs_sleep.rb
|
data/README
CHANGED
@@ -22,7 +22,7 @@ An Outbound Event Listener Example that reads and returns DTMF input:
|
|
22
22
|
Simply just create a subclass of FSR::Listner::Outbound and all
|
23
23
|
new calls/sessions will invoke the "session_initiated" callback method.
|
24
24
|
|
25
|
-
<b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next "freeswich command" is not executed until the previous "Freeswitch command" has finished. This is kicked off by "answer do"
|
25
|
+
<b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next "freeswich command" is not executed until the previous "Freeswitch command" has finished. (Basically a continuation) This is kicked off by "answer do".
|
26
26
|
|
27
27
|
#!/usr/bin/ruby
|
28
28
|
require 'fsr'
|
@@ -37,9 +37,9 @@ new calls/sessions will invoke the "session_initiated" callback method.
|
|
37
37
|
answer do
|
38
38
|
FSR::Log.info "***Reading DTMF from #{exten}"
|
39
39
|
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var|
|
40
|
-
FSR::Log.info "***Success, grabbed #{read_var.strip} from #{exten}"
|
40
|
+
FSR::Log.info "***Success, grabbed #{read_var.to_s.strip} from #{exten}"
|
41
41
|
# Tell the caller what they entered
|
42
|
-
speak("Got the DTMF of: #{read_var}") do
|
42
|
+
speak("Got the DTMF of: #{read_var.to_s.strip}") do
|
43
43
|
#Hangup the call
|
44
44
|
hangup
|
45
45
|
end
|
@@ -62,7 +62,7 @@ An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
|
62
62
|
|
63
63
|
# EXAMPLE 1
|
64
64
|
# This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next example
|
65
|
-
FSL::Inbound.add_event_hook(:CHANNEL_CREATE) {
|
65
|
+
FSL::Inbound.add_event_hook(:CHANNEL_CREATE) { FSR::Log.info "*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!" }
|
66
66
|
|
67
67
|
# EXAMPLE 2
|
68
68
|
# Define a method to handle CHANNEL_HANGUP events.
|
@@ -72,7 +72,7 @@ An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
|
72
72
|
end
|
73
73
|
|
74
74
|
# This adds a hook for EXAMPLE 2
|
75
|
-
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {
|
75
|
+
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) { custom_channel_hangup_handler(event) }
|
76
76
|
|
77
77
|
|
78
78
|
# Start FSR Inbound Listener
|
@@ -90,7 +90,7 @@ An Inbound Event Socket Listener example using the on_event callback method inst
|
|
90
90
|
|
91
91
|
class IesDemo < FSR::Listener::Inbound
|
92
92
|
|
93
|
-
def on_event
|
93
|
+
def on_event
|
94
94
|
pp event.headers
|
95
95
|
pp event.content[:event_name]
|
96
96
|
end
|
data/Rakefile
CHANGED
@@ -16,13 +16,17 @@ class OutboundDemo < FSR::Listener::Outbound
|
|
16
16
|
## NOTE YOU MUST MAKE SURE YOU PASS A VALID WAV FILE ##
|
17
17
|
#######################################################
|
18
18
|
read("/usr/local/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var|
|
19
|
-
FSR::Log.info "***Success, grabbed #{read_var.strip} from #{exten}"
|
19
|
+
FSR::Log.info "***Success, grabbed #{read_var.to_s.strip} from #{exten}"
|
20
20
|
# Tell the caller what they entered
|
21
21
|
# If you have mod_flite installed you should hear speech
|
22
|
-
speak("Got the DTMF of: #{read_var}") { hangup }
|
22
|
+
speak("Got the DTMF of: #{read_var.to_s.strip}") { hangup }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def receive_reply(reply)
|
27
|
+
FSR::Log.info "Received #{reply.inspect}"
|
28
|
+
end
|
29
|
+
|
26
30
|
end
|
27
31
|
|
28
32
|
end
|
data/freeswitcher.gemspec
CHANGED
@@ -2,137 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{freeswitcher}
|
5
|
-
s.version = "0.4.
|
5
|
+
s.version = "0.4.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jayson Vaughn", "Michael Fellinger", "Kevin Berry", "TJ Vanderpoel"]
|
9
|
-
s.date = %q{2009-
|
10
|
-
s.description = %q{=========================================================
|
11
|
-
FreeSWITCHeR
|
12
|
-
Copyright (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry)
|
13
|
-
Distributed under the terms of the MIT License.
|
14
|
-
==========================================================
|
15
|
-
|
16
|
-
ABOUT
|
17
|
-
-----
|
18
|
-
A ruby library for interacting with the "FreeSWITCH" (http://www.freeswitch.org) opensource telephony platform
|
19
|
-
|
20
|
-
REQUIREMENTS
|
21
|
-
------------
|
22
|
-
* ruby (>= 1.8)
|
23
|
-
* eventmachine (If you wish to use Outbound and Inbound listener)
|
24
|
-
|
25
|
-
USAGE
|
26
|
-
-----
|
27
|
-
|
28
|
-
An Outbound Event Listener Example that reads and returns DTMF input:
|
29
|
-
--------------------------------------------------------------------
|
30
|
-
|
31
|
-
Simply just create a subclass of FSR::Listner::Outbound and all
|
32
|
-
new calls/sessions will invoke the "session_initiated" callback method.
|
33
|
-
|
34
|
-
<b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next "freeswich command" is not executed until the previous "Freeswitch command" has finished. This is kicked off by "answer do"
|
35
|
-
|
36
|
-
#!/usr/bin/ruby
|
37
|
-
require 'fsr'
|
38
|
-
require 'fsr/listener/outbound'
|
39
|
-
|
40
|
-
class OutboundDemo < FSR::Listener::Outbound
|
41
|
-
|
42
|
-
def session_initiated
|
43
|
-
exten = @session.headers[:caller_caller_id_number]
|
44
|
-
FSR::Log.info "*** Answering incoming call from #{exten}"
|
45
|
-
|
46
|
-
answer do
|
47
|
-
FSR::Log.info "***Reading DTMF from #{exten}"
|
48
|
-
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var|
|
49
|
-
FSR::Log.info "***Success, grabbed #{read_var.strip} from #{exten}"
|
50
|
-
# Tell the caller what they entered
|
51
|
-
speak("Got the DTMF of: #{read_var}") do
|
52
|
-
#Hangup the call
|
53
|
-
hangup
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
FSR.start_oes! OutboundDemo, :port => 8084, :host => "127.0.0.1"
|
63
|
-
|
64
|
-
An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
65
|
-
--------------------------------------------------------------------------
|
66
|
-
|
67
|
-
#!/usr/bin/ruby
|
68
|
-
require 'pp'
|
69
|
-
require 'fsr'
|
70
|
-
require "fsr/listener/inbound"
|
71
|
-
|
72
|
-
# EXAMPLE 1
|
73
|
-
# This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next example
|
74
|
-
FSL::Inbound.add_event_hook(:CHANNEL_CREATE) {|event| FSR::Log.info "*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!" }
|
75
|
-
|
76
|
-
# EXAMPLE 2
|
77
|
-
# Define a method to handle CHANNEL_HANGUP events.
|
78
|
-
def custom_channel_hangup_handler(event)
|
79
|
-
FSR::Log.info "*** [#{event.content[:unique_id]}] Channel hangup. The event:"
|
80
|
-
pp event
|
81
|
-
end
|
82
|
-
|
83
|
-
# This adds a hook for EXAMPLE 2
|
84
|
-
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {|event| custom_channel_hangup_handler(event) }
|
85
|
-
|
86
|
-
|
87
|
-
# Start FSR Inbound Listener
|
88
|
-
FSR.start_ies!(FSL::Inbound, :host => "localhost", :port => 8021)
|
89
|
-
|
90
|
-
|
91
|
-
An Inbound Event Socket Listener example using the on_event callback method instead of hooks:
|
92
|
-
---------------------------------------------------------------------------------------------
|
93
|
-
|
94
|
-
#!/usr/bin/ruby
|
95
|
-
require 'pp'
|
96
|
-
require 'fsr'
|
97
|
-
require "fsr/listener/inbound"
|
98
|
-
|
99
|
-
|
100
|
-
class IesDemo < FSR::Listener::Inbound
|
101
|
-
|
102
|
-
def on_event(event)
|
103
|
-
pp event.headers
|
104
|
-
pp event.content[:event_name]
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021, :auth => "ClueCon")
|
110
|
-
|
111
|
-
|
112
|
-
An example of using FSR::CommandSocket to originate a new call in irb:
|
113
|
-
----------------------------------------------------------------------
|
114
|
-
|
115
|
-
irb(main):001:0> require 'fsr'
|
116
|
-
=> true
|
117
|
-
|
118
|
-
irb(main):002:0> FSR.load_all_commands
|
119
|
-
=> [:sofia, :originate]
|
120
|
-
|
121
|
-
irb(main):003:0> sock = FSR::CommandSocket.new
|
122
|
-
=> #<FSR::CommandSocket:0xb7a89104 @server="127.0.0.1", @socket=#<TCPSocket:0xb7a8908c>, @port="8021", @auth="ClueCon">
|
123
|
-
|
124
|
-
irb(main):007:0> sock.originate(:target => 'sofia/gateway/carlos/8179395222', :endpoint => FSR::App::Bridge.new("user/bougyman")).run
|
125
|
-
=> {"Job-UUID"=>"732075a4-7dd5-4258-b124-6284a82a5ae7", "body"=>"", "Content-Type"=>"command/reply", "Reply-Text"=>"+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7"}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
SUPPORT
|
130
|
-
-------
|
131
|
-
Home page at http://code.rubyists.com/projects/fs
|
132
|
-
#rubyists on FreeNode
|
133
|
-
}
|
9
|
+
s.date = %q{2009-11-18}
|
10
|
+
s.description = %q{========================================================= FreeSWITCHeR Copyright (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry) Distributed under the terms of the MIT License. ========================================================== ABOUT ----- A ruby library for interacting with the "FreeSWITCH" (http://www.freeswitch.org) opensource telephony platform REQUIREMENTS ------------ * ruby (>= 1.8) * eventmachine (If you wish to use Outbound and Inbound listener) USAGE ----- An Outbound Event Listener Example that reads and returns DTMF input: -------------------------------------------------------------------- Simply just create a subclass of FSR::Listner::Outbound and all new calls/sessions will invoke the "session_initiated" callback method. <b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next "freeswich command" is not executed until the previous "Freeswitch command" has finished. (Basically a continuation) This is kicked off by "answer do". #!/usr/bin/ruby require 'fsr' require 'fsr/listener/outbound' class OutboundDemo < FSR::Listener::Outbound def session_initiated exten = @session.headers[:caller_caller_id_number] FSR::Log.info "*** Answering incoming call from #{exten}" answer do FSR::Log.info "***Reading DTMF from #{exten}" read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var| FSR::Log.info "***Success, grabbed #{read_var.to_s.strip} from #{exten}" # Tell the caller what they entered speak("Got the DTMF of: #{read_var.to_s.strip}") do #Hangup the call hangup end end end end end FSR.start_oes! OutboundDemo, :port => 8084, :host => "127.0.0.1" An Inbound Event Socket Listener example using FreeSWITCHeR's hook system: -------------------------------------------------------------------------- #!/usr/bin/ruby require 'pp' require 'fsr' require "fsr/listener/inbound" # EXAMPLE 1 # This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next example FSL::Inbound.add_event_hook(:CHANNEL_CREATE) { FSR::Log.info "*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!" } # EXAMPLE 2 # Define a method to handle CHANNEL_HANGUP events. def custom_channel_hangup_handler(event) FSR::Log.info "*** [#{event.content[:unique_id]}] Channel hangup. The event:" pp event end # This adds a hook for EXAMPLE 2 FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) { custom_channel_hangup_handler(event) } # Start FSR Inbound Listener FSR.start_ies!(FSL::Inbound, :host => "localhost", :port => 8021) An Inbound Event Socket Listener example using the on_event callback method instead of hooks: --------------------------------------------------------------------------------------------- #!/usr/bin/ruby require 'pp' require 'fsr' require "fsr/listener/inbound" class IesDemo < FSR::Listener::Inbound def on_event pp event.headers pp event.content[:event_name] end end FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021, :auth => "ClueCon") An example of using FSR::CommandSocket to originate a new call in irb: ---------------------------------------------------------------------- irb(main):001:0> require 'fsr' => true irb(main):002:0> FSR.load_all_commands => [:sofia, :originate] irb(main):003:0> sock = FSR::CommandSocket.new => #<FSR::CommandSocket:0xb7a89104 @server="127.0.0.1", @socket=#<TCPSocket:0xb7a8908c>, @port="8021", @auth="ClueCon"> irb(main):007:0> sock.originate(:target => 'sofia/gateway/carlos/8179395222', :endpoint => FSR::App::Bridge.new("user/bougyman")).run => {"Job-UUID"=>"732075a4-7dd5-4258-b124-6284a82a5ae7", "body"=>"", "Content-Type"=>"command/reply", "Reply-Text"=>"+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7"} SUPPORT ------- Home page at http://code.rubyists.com/projects/fs #rubyists on FreeNode}
|
134
11
|
s.email = %q{FreeSWITCHeR@rubyists.com}
|
135
|
-
s.files = [".gitignore", "AUTHORS", "CHANGELOG", "License.txt", "MANIFEST", "NEWS", "README", "Rakefile", "examples/inbound_event_socket.rb", "examples/inbound_socket_events.rb", "examples/outbound_event_socket.rb", "freeswitcher.gemspec", "lib/fsr.rb", "lib/fsr/app.rb", "lib/fsr/app/answer.rb", "lib/fsr/app/bridge.rb", "lib/fsr/app/conference.rb", "lib/fsr/app/fifo.rb", "lib/fsr/app/fs_break.rb", "lib/fsr/app/fs_sleep.rb", "lib/fsr/app/hangup.rb", "lib/fsr/app/limit.rb", "lib/fsr/app/log.rb", "lib/fsr/app/play_and_get_digits.rb", "lib/fsr/app/playback.rb", "lib/fsr/app/read.rb", "lib/fsr/app/set.rb", "lib/fsr/app/speak.rb", "lib/fsr/app/transfer.rb", "lib/fsr/app/uuid_dump.rb", "lib/fsr/app/uuid_getvar.rb", "lib/fsr/app/uuid_setvar.rb", "lib/fsr/cmd.rb", "lib/fsr/cmd/calls.rb", "lib/fsr/cmd/fsctl.rb", "lib/fsr/cmd/originate.rb", "lib/fsr/cmd/sofia.rb", "lib/fsr/cmd/sofia/profile.rb", "lib/fsr/cmd/sofia/status.rb", "lib/fsr/cmd/sofia_contact.rb", "lib/fsr/cmd/status.rb", "lib/fsr/cmd/uuid_dump.rb", "lib/fsr/command_socket.rb", "lib/fsr/database.rb", "lib/fsr/database/call_limit.rb", "lib/fsr/database/core.rb", "lib/fsr/database/sofia_reg_external.rb", "lib/fsr/database/sofia_reg_internal.rb", "lib/fsr/database/voicemail_default.rb", "lib/fsr/event_socket.rb", "lib/fsr/fake_socket.rb", "lib/fsr/listener.rb", "lib/fsr/listener/header_and_content_response.rb", "lib/fsr/listener/inbound.rb", "lib/fsr/listener/inbound/event.rb", "lib/fsr/listener/mock.rb", "lib/fsr/listener/outbound.rb", "lib/fsr/model/call.rb", "lib/fsr/version.rb", "tasks/authors.rake", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/copyright.rake", "tasks/gem.rake", "tasks/gem_installer.rake", "tasks/install_dependencies.rake", "tasks/manifest.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/spec.rake", "tasks/yard.rake", "spec/helper.rb", "spec/fsr_listener_helper.rb", "spec/fsr/app.rb", "spec/fsr/app/answer.rb", "spec/fsr/app/bridge.rb", "spec/fsr/app/conference.rb", "spec/fsr/app/fifo.rb", "spec/fsr/app/fs_break.rb", "spec/fsr/app/fs_sleep.rb", "spec/fsr/app/hangup.rb", "spec/fsr/app/limit.rb", "spec/fsr/app/log.rb", "spec/fsr/app/play_and_get_digits.rb", "spec/fsr/app/playback.rb", "spec/fsr/app/set.rb", "spec/fsr/app/transfer.rb", "spec/fsr/cmd.rb", "spec/fsr/cmd/calls.rb", "spec/fsr/cmd/originate.rb", "spec/fsr/cmd/sofia.rb", "spec/fsr/cmd/sofia/profile.rb", "spec/fsr/cmd/uuid_dump.rb", "spec/fsr/listener.rb", "spec/fsr/listener/header_and_content_response.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
12
|
+
s.files = [".gitignore", "AUTHORS", "CHANGELOG", "License.txt", "MANIFEST", "NEWS", "README", "Rakefile", "examples/inbound_event_socket.rb", "examples/inbound_socket_events.rb", "examples/outbound_event_socket.rb", "freeswitcher.gemspec", "lib/fsr.rb", "lib/fsr/app.rb", "lib/fsr/app/answer.rb", "lib/fsr/app/bind_meta_app.rb", "lib/fsr/app/bridge.rb", "lib/fsr/app/conference.rb", "lib/fsr/app/execute_app.rb", "lib/fsr/app/fifo.rb", "lib/fsr/app/fs_break.rb", "lib/fsr/app/fs_sleep.rb", "lib/fsr/app/hangup.rb", "lib/fsr/app/limit.rb", "lib/fsr/app/log.rb", "lib/fsr/app/play_and_get_digits.rb", "lib/fsr/app/playback.rb", "lib/fsr/app/read.rb", "lib/fsr/app/set.rb", "lib/fsr/app/speak.rb", "lib/fsr/app/transfer.rb", "lib/fsr/app/uuid_dump.rb", "lib/fsr/app/uuid_getvar.rb", "lib/fsr/app/uuid_setvar.rb", "lib/fsr/cmd.rb", "lib/fsr/cmd/calls.rb", "lib/fsr/cmd/fsctl.rb", "lib/fsr/cmd/originate.rb", "lib/fsr/cmd/sofia.rb", "lib/fsr/cmd/sofia/profile.rb", "lib/fsr/cmd/sofia/status.rb", "lib/fsr/cmd/sofia_contact.rb", "lib/fsr/cmd/status.rb", "lib/fsr/cmd/uuid_dump.rb", "lib/fsr/command_socket.rb", "lib/fsr/database.rb", "lib/fsr/database/call_limit.rb", "lib/fsr/database/core.rb", "lib/fsr/database/sofia_reg_external.rb", "lib/fsr/database/sofia_reg_internal.rb", "lib/fsr/database/voicemail_default.rb", "lib/fsr/event_socket.rb", "lib/fsr/fake_socket.rb", "lib/fsr/listener.rb", "lib/fsr/listener/header_and_content_response.rb", "lib/fsr/listener/inbound.rb", "lib/fsr/listener/inbound/event.rb", "lib/fsr/listener/mock.rb", "lib/fsr/listener/outbound.rb", "lib/fsr/model/call.rb", "lib/fsr/version.rb", "tasks/authors.rake", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/copyright.rake", "tasks/gem.rake", "tasks/gem_installer.rake", "tasks/install_dependencies.rake", "tasks/manifest.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/spec.rake", "tasks/yard.rake", "spec/helper.rb", "spec/fsr_listener_helper.rb", "spec/fsr/app.rb", "spec/fsr/app/answer.rb", "spec/fsr/app/bind_meta_app.rb", "spec/fsr/app/bridge.rb", "spec/fsr/app/conference.rb", "spec/fsr/app/execute_app.rb", "spec/fsr/app/fifo.rb", "spec/fsr/app/fs_break.rb", "spec/fsr/app/fs_sleep.rb", "spec/fsr/app/hangup.rb", "spec/fsr/app/limit.rb", "spec/fsr/app/log.rb", "spec/fsr/app/play_and_get_digits.rb", "spec/fsr/app/playback.rb", "spec/fsr/app/set.rb", "spec/fsr/app/transfer.rb", "spec/fsr/cmd.rb", "spec/fsr/cmd/calls.rb", "spec/fsr/cmd/originate.rb", "spec/fsr/cmd/sofia.rb", "spec/fsr/cmd/sofia/profile.rb", "spec/fsr/cmd/uuid_dump.rb", "spec/fsr/listener.rb", "spec/fsr/listener/header_and_content_response.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
136
13
|
s.homepage = %q{http://code.rubyists.com/projects/fs}
|
137
14
|
s.post_install_message = %q{=========================================================
|
138
15
|
FreeSWITCHeR
|
@@ -158,7 +35,7 @@ An Outbound Event Listener Example that reads and returns DTMF input:
|
|
158
35
|
Simply just create a subclass of FSR::Listner::Outbound and all
|
159
36
|
new calls/sessions will invoke the "session_initiated" callback method.
|
160
37
|
|
161
|
-
<b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next "freeswich command" is not executed until the previous "Freeswitch command" has finished. This is kicked off by "answer do"
|
38
|
+
<b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next "freeswich command" is not executed until the previous "Freeswitch command" has finished. (Basically a continuation) This is kicked off by "answer do".
|
162
39
|
|
163
40
|
#!/usr/bin/ruby
|
164
41
|
require 'fsr'
|
@@ -173,9 +50,9 @@ new calls/sessions will invoke the "session_initiated" callback method.
|
|
173
50
|
answer do
|
174
51
|
FSR::Log.info "***Reading DTMF from #{exten}"
|
175
52
|
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var|
|
176
|
-
FSR::Log.info "***Success, grabbed #{read_var.strip} from #{exten}"
|
53
|
+
FSR::Log.info "***Success, grabbed #{read_var.to_s.strip} from #{exten}"
|
177
54
|
# Tell the caller what they entered
|
178
|
-
speak("Got the DTMF of: #{read_var}") do
|
55
|
+
speak("Got the DTMF of: #{read_var.to_s.strip}") do
|
179
56
|
#Hangup the call
|
180
57
|
hangup
|
181
58
|
end
|
@@ -198,7 +75,7 @@ An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
|
198
75
|
|
199
76
|
# EXAMPLE 1
|
200
77
|
# This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next example
|
201
|
-
FSL::Inbound.add_event_hook(:CHANNEL_CREATE) {
|
78
|
+
FSL::Inbound.add_event_hook(:CHANNEL_CREATE) { FSR::Log.info "*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!" }
|
202
79
|
|
203
80
|
# EXAMPLE 2
|
204
81
|
# Define a method to handle CHANNEL_HANGUP events.
|
@@ -208,7 +85,7 @@ An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
|
208
85
|
end
|
209
86
|
|
210
87
|
# This adds a hook for EXAMPLE 2
|
211
|
-
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {
|
88
|
+
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) { custom_channel_hangup_handler(event) }
|
212
89
|
|
213
90
|
|
214
91
|
# Start FSR Inbound Listener
|
@@ -226,7 +103,7 @@ An Inbound Event Socket Listener example using the on_event callback method inst
|
|
226
103
|
|
227
104
|
class IesDemo < FSR::Listener::Inbound
|
228
105
|
|
229
|
-
def on_event
|
106
|
+
def on_event
|
230
107
|
pp event.headers
|
231
108
|
pp event.content[:event_name]
|
232
109
|
end
|
@@ -260,13 +137,13 @@ Home page at http://code.rubyists.com/projects/fs
|
|
260
137
|
}
|
261
138
|
s.require_paths = ["lib"]
|
262
139
|
s.rubyforge_project = %q{freeswitcher}
|
263
|
-
s.rubygems_version = %q{1.3.
|
140
|
+
s.rubygems_version = %q{1.3.1}
|
264
141
|
s.summary = %q{A library for interacting with the "FreeSWITCH":http://freeswitch.org telephony platform}
|
265
|
-
s.test_files = ["spec/fsr/app.rb", "spec/fsr/app/answer.rb", "spec/fsr/app/bridge.rb", "spec/fsr/app/conference.rb", "spec/fsr/app/fifo.rb", "spec/fsr/app/fs_break.rb", "spec/fsr/app/fs_sleep.rb", "spec/fsr/app/hangup.rb", "spec/fsr/app/limit.rb", "spec/fsr/app/log.rb", "spec/fsr/app/play_and_get_digits.rb", "spec/fsr/app/playback.rb", "spec/fsr/app/set.rb", "spec/fsr/app/transfer.rb", "spec/fsr/cmd.rb", "spec/fsr/cmd/calls.rb", "spec/fsr/cmd/originate.rb", "spec/fsr/cmd/sofia.rb", "spec/fsr/cmd/sofia/profile.rb", "spec/fsr/cmd/uuid_dump.rb", "spec/fsr/listener.rb", "spec/fsr/listener/header_and_content_response.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
142
|
+
s.test_files = ["spec/fsr/app.rb", "spec/fsr/app/answer.rb", "spec/fsr/app/bind_meta_app.rb", "spec/fsr/app/bridge.rb", "spec/fsr/app/conference.rb", "spec/fsr/app/execute_app.rb", "spec/fsr/app/fifo.rb", "spec/fsr/app/fs_break.rb", "spec/fsr/app/fs_sleep.rb", "spec/fsr/app/hangup.rb", "spec/fsr/app/limit.rb", "spec/fsr/app/log.rb", "spec/fsr/app/play_and_get_digits.rb", "spec/fsr/app/playback.rb", "spec/fsr/app/set.rb", "spec/fsr/app/transfer.rb", "spec/fsr/cmd.rb", "spec/fsr/cmd/calls.rb", "spec/fsr/cmd/originate.rb", "spec/fsr/cmd/sofia.rb", "spec/fsr/cmd/sofia/profile.rb", "spec/fsr/cmd/uuid_dump.rb", "spec/fsr/listener.rb", "spec/fsr/listener/header_and_content_response.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
266
143
|
|
267
144
|
if s.respond_to? :specification_version then
|
268
145
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
269
|
-
s.specification_version =
|
146
|
+
s.specification_version = 2
|
270
147
|
|
271
148
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
272
149
|
s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
|