bougyman-freeswitcher 0.1.4 → 0.3.0
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 +0 -10
- data/CHANGELOG +123 -0
- data/MANIFEST +3 -9
- data/README +57 -60
- data/Rakefile +4 -4
- data/examples/outbound_event_socket.rb +2 -5
- data/freeswitcher.gemspec +62 -65
- data/lib/fsr/app.rb +1 -3
- data/lib/fsr/app/answer.rb +2 -0
- data/lib/fsr/app/play_and_get_digits.rb +11 -1
- data/lib/fsr/app/read.rb +12 -2
- data/lib/fsr/app/uuid_getvar.rb +13 -2
- data/lib/fsr/app/uuid_setvar.rb +11 -1
- data/lib/fsr/cmd.rb +22 -4
- data/lib/fsr/cmd/originate.rb +23 -6
- data/lib/fsr/command_socket.rb +1 -1
- data/lib/fsr/listener/inbound.rb +19 -10
- data/lib/fsr/listener/outbound.rb +75 -18
- data/lib/fsr/version.rb +1 -1
- data/spec/fsr/app/answer.rb +12 -0
- data/spec/fsr/app/fs_break.rb +12 -0
- data/spec/fsr/app/fs_sleep.rb +12 -0
- data/spec/fsr/cmd/originate.rb +32 -0
- metadata +62 -68
- data/examples/bin/cmd_demo.rb +0 -19
- data/examples/bin/dtmf_test.rb +0 -38
- data/examples/bin/ies_demo.rb +0 -19
- data/examples/bin/ies_demo_with_hook.rb +0 -25
- data/examples/bin/oes_demo.rb +0 -22
- data/examples/dtmf_test.rb +0 -35
- data/examples/ies_demo.rb +0 -19
- data/examples/ies_demo_with_hook.rb +0 -25
- data/lib/fsr/listener/outbound.rb.orig +0 -131
data/AUTHORS
CHANGED
@@ -1,13 +1,3 @@
|
|
1
1
|
Following persons have contributed to freeswitcher.
|
2
2
|
(Sorted by number of submitted patches, then alphabetically)
|
3
3
|
|
4
|
-
103 TJ Vanderpoel <bougy.man@gmail.com>
|
5
|
-
64 Jayson Vaughn <jayson@onedrop.home>
|
6
|
-
28 Michael Fellinger <m.fellinger@gmail.com>
|
7
|
-
6 Jayson Vaughn <jayson@onedrop.(none)>
|
8
|
-
6 Mikael Bjerkeland <mikael@consoll.no>
|
9
|
-
4 foo <jvaughn@hellspass.nationwide-recovery.com>
|
10
|
-
4 Jayson Vaughn <vaughn.jayson@gmail.com>
|
11
|
-
3 Kevin Berry <kevin@opensourcealchemist.com>
|
12
|
-
1 jayson vaughn <jayson@falcon.(none)>
|
13
|
-
1 U-Paul-PC\Paul <Paul@Paul-PC.(none)>
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,126 @@
|
|
1
|
+
[bf6befa | Mon May 18 23:22:36 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
2
|
+
|
3
|
+
* functionality for receiving variables passed to a block complete. README updated. Convert Rakefile file options to Pathname
|
4
|
+
|
5
|
+
[7b0bf11 | Mon May 18 20:31:48 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
6
|
+
|
7
|
+
* Added yardoc comments
|
8
|
+
|
9
|
+
[7b7efa7 | Mon May 18 20:10:30 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
10
|
+
|
11
|
+
* Removed FSR::Log.info debugging line from uuid_getvar and setvar
|
12
|
+
|
13
|
+
[fda2ff4 | Mon May 18 19:55:19 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
14
|
+
|
15
|
+
* Added FSR::App::UuidGetVar and UuidSetVar
|
16
|
+
|
17
|
+
[39338cd | Mon May 18 18:55:17 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
18
|
+
|
19
|
+
* Corrected typo s/header_and_content/header_and_content_hash
|
20
|
+
|
21
|
+
[cb4d1cc | Mon May 18 18:54:08 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
22
|
+
|
23
|
+
* And also it seems I need to include a parameter for hash_header in
|
24
|
+
|
25
|
+
[a818d62 | Mon May 18 18:51:25 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
26
|
+
|
27
|
+
* Need to add a second paremeter to check_for_updated_session that
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
[6302892 | Mon May 18 18:49:17 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
32
|
+
|
33
|
+
* Changed session_header_and_content to header_and_content_hash
|
34
|
+
|
35
|
+
[5b8d9a4 | Mon May 18 18:47:57 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
36
|
+
|
37
|
+
* Corrected some typos in previous refactor of Outbound#receive_reply
|
38
|
+
|
39
|
+
[12a13eb | Mon May 18 18:41:40 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
40
|
+
|
41
|
+
* Refactored Outbound#receive_request to decouple it a tad. Still could
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
[6a95fa1 | Mon May 18 18:16:43 UTC 2009] Jayson Vaughn <jayson@onedrop.nationwide-recovery.com>
|
46
|
+
|
47
|
+
* Refactored FSR::App::PlayAndGetDigits to now yeild the read_var in a
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
[5093e71 | Mon May 18 15:08:39 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
52
|
+
|
53
|
+
* Read will now yield the read variable in a block
|
54
|
+
|
55
|
+
Updated README
|
56
|
+
|
57
|
+
[e71a1a5 | Mon May 18 01:55:43 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
58
|
+
|
59
|
+
* reverted design error, putting SENDMSG_METHOD into Read attaching to Outbound, not App
|
60
|
+
|
61
|
+
[273bdaf | Mon May 18 01:34:02 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
62
|
+
|
63
|
+
* removed &block from read method definition after failing spec
|
64
|
+
|
65
|
+
[ad1bbd1 | Mon May 18 00:37:44 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
66
|
+
|
67
|
+
* left out another to_sym
|
68
|
+
|
69
|
+
[19f8581 | Mon May 18 00:32:23 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
70
|
+
|
71
|
+
* left out a to_sym
|
72
|
+
|
73
|
+
[f445058 | Mon May 18 00:31:43 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
74
|
+
|
75
|
+
* typos galore, fixed wrong constant name in Read. created the queue_pop method to handle popping procs, adding the session.headers[@read_var] if it exist to the proc called
|
76
|
+
|
77
|
+
[93ecad2 | Mon May 18 00:19:16 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
78
|
+
|
79
|
+
* TEST push to test changes, read/outbound test needed
|
80
|
+
|
81
|
+
[30a39ad | Sat May 16 20:41:41 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
82
|
+
|
83
|
+
* Added specs for originate, defaults to Cmd
|
84
|
+
|
85
|
+
* Added specs for failing cases of Cmd::Originate
|
86
|
+
* Move DEFAULT_OPTIONS to FSR::Cmd::Command so commands inherit this
|
87
|
+
* Move default_options method to FSR::Cmd::Command as well.
|
88
|
+
* Used default_options block in Originate for options population
|
89
|
+
|
90
|
+
[865d177 | Sat May 16 17:56:45 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
91
|
+
|
92
|
+
* filling out originate specs, testing options and argument types
|
93
|
+
|
94
|
+
[19b81ff | Wed May 13 16:03:35 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
95
|
+
|
96
|
+
* refactored to a new default_options
|
97
|
+
|
98
|
+
[081112a | Wed May 13 15:32:20 UTC 2009] TJ Vanderpoel <bougy.man@gmail.com>
|
99
|
+
|
100
|
+
* changed handling of :ignore_early_media in target_options of originate to behave properly. Added argument checks for some originate arguments
|
101
|
+
|
102
|
+
[55ec1c5 | Mon May 11 17:14:34 UTC 2009] Jayson Vaughn <jayson@onedrop.(none)>
|
103
|
+
|
104
|
+
* New specs now pass
|
105
|
+
|
106
|
+
[ab262c9 | Mon May 11 17:13:48 UTC 2009] Jayson Vaughn <jayson@onedrop.(none)>
|
107
|
+
|
108
|
+
* Added specs for FSR::App::Answer, FSBreak, and FSSleep
|
109
|
+
|
110
|
+
[1faf55f | Mon May 11 16:44:51 UTC 2009] Jayson Vaughn <jayson@onedrop.(none)>
|
111
|
+
|
112
|
+
* Updated gemspec for 0.1.4
|
113
|
+
|
114
|
+
[011a3e6 | Mon May 11 16:43:14 UTC 2009] Jayson Vaughn <jayson@onedrop.(none)>
|
115
|
+
|
116
|
+
* Sync changes with Master
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
[f036509 | Mon May 11 16:36:04 UTC 2009] Jayson Vaughn <jayson@onedrop.(none)>
|
121
|
+
|
122
|
+
* Version 0.1.4
|
123
|
+
|
1
124
|
[a110dc6 | Mon May 11 16:12:17 UTC 2009] Jayson Vaughn <jayson@onedrop.(none)>
|
2
125
|
|
3
126
|
* Corrected typos in README
|
data/MANIFEST
CHANGED
@@ -6,14 +6,6 @@ MANIFEST
|
|
6
6
|
NEWS
|
7
7
|
README
|
8
8
|
Rakefile
|
9
|
-
examples/bin/cmd_demo.rb
|
10
|
-
examples/bin/dtmf_test.rb
|
11
|
-
examples/bin/ies_demo.rb
|
12
|
-
examples/bin/ies_demo_with_hook.rb
|
13
|
-
examples/bin/oes_demo.rb
|
14
|
-
examples/dtmf_test.rb
|
15
|
-
examples/ies_demo.rb
|
16
|
-
examples/ies_demo_with_hook.rb
|
17
9
|
examples/inbound_event_socket.rb
|
18
10
|
examples/inbound_socket_events.rb
|
19
11
|
examples/outbound_event_socket.rb
|
@@ -61,7 +53,6 @@ lib/fsr/listener/header_and_content_response.rb
|
|
61
53
|
lib/fsr/listener/inbound.rb
|
62
54
|
lib/fsr/listener/inbound/event.rb
|
63
55
|
lib/fsr/listener/outbound.rb
|
64
|
-
lib/fsr/listener/outbound.rb.orig
|
65
56
|
lib/fsr/model/call.rb
|
66
57
|
lib/fsr/version.rb
|
67
58
|
tasks/authors.rake
|
@@ -80,9 +71,12 @@ tasks/spec.rake
|
|
80
71
|
tasks/yard.rake
|
81
72
|
spec/helper.rb
|
82
73
|
spec/fsr/app.rb
|
74
|
+
spec/fsr/app/answer.rb
|
83
75
|
spec/fsr/app/bridge.rb
|
84
76
|
spec/fsr/app/conference.rb
|
85
77
|
spec/fsr/app/fifo.rb
|
78
|
+
spec/fsr/app/fs_break.rb
|
79
|
+
spec/fsr/app/fs_sleep.rb
|
86
80
|
spec/fsr/app/hangup.rb
|
87
81
|
spec/fsr/app/limit.rb
|
88
82
|
spec/fsr/app/log.rb
|
data/README
CHANGED
@@ -10,8 +10,8 @@ A ruby library for interacting with the "FreeSWITCH" (http://www.freeswitch.org)
|
|
10
10
|
|
11
11
|
REQUIREMENTS
|
12
12
|
------------
|
13
|
-
|
14
|
-
|
13
|
+
* ruby (>= 1.8)
|
14
|
+
* eventmachine (If you wish to use Outbound and Inbound listener)
|
15
15
|
|
16
16
|
USAGE
|
17
17
|
-----
|
@@ -22,97 +22,94 @@ 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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
class OutboundDemo < FSR::Listener::Outbound
|
33
|
-
|
34
|
-
def session_initiated
|
35
|
-
exten = @session.headers[:caller_caller_id_number]
|
36
|
-
FSR::Log.info "*** Answering incoming call from #{exten}"
|
37
|
-
|
38
|
-
answer do
|
39
|
-
FSR::Log.info "***Reading DTMF from #{exten}"
|
40
|
-
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do
|
41
|
-
FSR::Log.info "*** Updating session for #{exten}"
|
42
|
-
update_session do
|
43
|
-
FSR::Log.info "***Success, grabbed #{@session.headers[:variable_input].strip} from #{exten}"
|
44
|
-
hangup #Hangup the call
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
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"
|
26
|
+
|
27
|
+
#!/usr/bin/ruby
|
28
|
+
require 'fsr'
|
29
|
+
require 'fsr/listener/outbound'
|
30
|
+
|
31
|
+
class OutboundDemo < FSR::Listener::Outbound
|
48
32
|
|
33
|
+
def session_initiated
|
34
|
+
exten = @session.headers[:caller_caller_id_number]
|
35
|
+
FSR::Log.info "*** Answering incoming call from #{exten}"
|
36
|
+
|
37
|
+
answer do
|
38
|
+
FSR::Log.info "***Reading DTMF from #{exten}"
|
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}"
|
41
|
+
hangup #Hangup the call
|
42
|
+
end
|
49
43
|
end
|
50
44
|
|
51
45
|
end
|
52
46
|
|
53
|
-
|
47
|
+
end
|
54
48
|
|
49
|
+
FSR.start_oes! OutboundDemo, :port => 8084, :host => "127.0.0.1"
|
55
50
|
|
56
51
|
An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
57
52
|
--------------------------------------------------------------------------
|
58
53
|
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
#!/usr/bin/ruby
|
55
|
+
require 'pp'
|
56
|
+
require 'fsr'
|
57
|
+
require "fsr/listener/inbound"
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
# EXAMPLE 1
|
60
|
+
# 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
|
61
|
+
FSL::Inbound.add_event_hook(:CHANNEL_CREATE) {|event| FSR::Log.info "*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!" }
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
# EXAMPLE 2
|
64
|
+
# Define a method to handle CHANNEL_HANGUP events.
|
65
|
+
def custom_channel_hangup_handler(event)
|
66
|
+
FSR::Log.info "*** [#{event.content[:unique_id]}] Channel hangup. The event:"
|
67
|
+
pp event
|
68
|
+
end
|
73
69
|
|
74
|
-
|
75
|
-
|
70
|
+
# This adds a hook for EXAMPLE 2
|
71
|
+
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {|event| custom_channel_hangup_handler(event) }
|
76
72
|
|
77
73
|
|
78
|
-
|
79
|
-
|
74
|
+
# Start FSR Inbound Listener
|
75
|
+
FSR.start_ies!(FSL::Inbound, :host => "localhost", :port => 8021)
|
80
76
|
|
81
77
|
|
82
78
|
An Inbound Event Socket Listener example using the on_event callback method instead of hooks:
|
83
79
|
---------------------------------------------------------------------------------------------
|
84
80
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
81
|
+
#!/usr/bin/ruby
|
82
|
+
require 'pp'
|
83
|
+
require 'fsr'
|
84
|
+
require "fsr/listener/inbound"
|
89
85
|
|
90
|
-
class IesDemo < FSR::Listener::Inbound
|
91
86
|
|
92
|
-
|
93
|
-
pp event.headers
|
94
|
-
pp event.content[:event_name]
|
95
|
-
end
|
87
|
+
class IesDemo < FSR::Listener::Inbound
|
96
88
|
|
89
|
+
def on_event(event)
|
90
|
+
pp event.headers
|
91
|
+
pp event.content[:event_name]
|
97
92
|
end
|
98
93
|
|
99
|
-
|
94
|
+
end
|
95
|
+
|
96
|
+
FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021)
|
100
97
|
|
101
98
|
|
102
99
|
An example of using FSR::CommandSocket to originate a new call in irb:
|
103
100
|
----------------------------------------------------------------------
|
104
101
|
|
105
|
-
|
106
|
-
|
102
|
+
irb(main):001:0> require 'fsr'
|
103
|
+
=> true
|
107
104
|
|
108
|
-
|
109
|
-
|
105
|
+
irb(main):002:0> FSR.load_all_commands
|
106
|
+
=> [:sofia, :originate]
|
110
107
|
|
111
|
-
|
112
|
-
|
108
|
+
irb(main):003:0> sock = FSR::CommandSocket.new
|
109
|
+
=> #<FSR::CommandSocket:0xb7a89104 @server="127.0.0.1", @socket=#<TCPSocket:0xb7a8908c>, @port="8021", @auth="ClueCon">
|
113
110
|
|
114
|
-
|
115
|
-
|
111
|
+
irb(main):007:0> sock.originate(:target => 'sofia/gateway/carlos/8179395222', :endpoint => FSR::App::Bridge.new("user/bougyman")).run
|
112
|
+
=> {"Job-UUID"=>"732075a4-7dd5-4258-b124-6284a82a5ae7", "body"=>"", "Content-Type"=>"command/reply", "Reply-Text"=>"+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7"}
|
116
113
|
|
117
114
|
|
118
115
|
|
data/Rakefile
CHANGED
@@ -3,13 +3,13 @@ require "rubygems"
|
|
3
3
|
require "lib/fsr"
|
4
4
|
require "pathname"
|
5
5
|
|
6
|
-
PROJECT_COPYRIGHT =
|
7
|
-
PROJECT_README = Pathname
|
6
|
+
PROJECT_COPYRIGHT = Pathname(__FILE__).dirname.join("License.txt").read
|
7
|
+
PROJECT_README = Pathname(__FILE__).dirname.join("README").expand_path.to_s
|
8
8
|
PROJECT_FILES = %x{git ls-files}.split
|
9
9
|
RELEASE_FILES = PROJECT_FILES.reject { |f| f.match(/^(?:contrib)(?:\/|$)/) }
|
10
10
|
GEM_FILES = RELEASE_FILES.reject { |f| f.match(/^(?:spec)(?:\/|$)/) }
|
11
11
|
PROJECT_SPECS = (RELEASE_FILES - GEM_FILES).reject { |d| d.match(/(?:helper.rb)$/) }
|
12
|
-
GEM_FILES << "spec/helper.rb" if Pathname
|
12
|
+
GEM_FILES << "spec/helper.rb" if Pathname("spec/helper.rb").file?
|
13
13
|
|
14
14
|
|
15
15
|
GEMSPEC = Gem::Specification.new do |spec|
|
@@ -25,7 +25,7 @@ GEMSPEC = Gem::Specification.new do |spec|
|
|
25
25
|
spec.test_files = PROJECT_SPECS
|
26
26
|
spec.require_path = "lib"
|
27
27
|
|
28
|
-
description =
|
28
|
+
description = Pathname(PROJECT_README).read
|
29
29
|
spec.description = description
|
30
30
|
spec.rubyforge_project = "freeswitcher"
|
31
31
|
spec.post_install_message = description
|
@@ -12,12 +12,9 @@ class OutboundDemo < FSR::Listener::Outbound
|
|
12
12
|
|
13
13
|
answer do
|
14
14
|
FSR::Log.info "***Reading DTMF from #{exten}"
|
15
|
-
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do
|
16
|
-
|
17
|
-
update_session do
|
18
|
-
FSR::Log.info "***Success, grabbed #{@session.headers[:variable_input].strip} from #{exten}"
|
15
|
+
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var|
|
16
|
+
FSR::Log.info "***Success, grabbed #{read_var.strip} from #{exten}"
|
19
17
|
hangup #Hangup the call
|
20
|
-
end
|
21
18
|
end
|
22
19
|
end
|
23
20
|
|
data/freeswitcher.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{freeswitcher}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
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-05-
|
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 ------------
|
9
|
+
s.date = %q{2009-05-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. 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.strip} from #{exten}" hangup #Hangup the call 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) {|event| 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) {|event| 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(event) pp event.headers pp event.content[:event_name] end end FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021) 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}
|
11
11
|
s.email = %q{FreeSWITCHeR@rubyists.com}
|
12
|
-
s.files = [".gitignore", "AUTHORS", "CHANGELOG", "License.txt", "MANIFEST", "NEWS", "README", "Rakefile", "examples/
|
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/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/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/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/rcov.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/spec.rake", "tasks/yard.rake", "spec/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/listener.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
13
13
|
s.homepage = %q{http://code.rubyists.com/projects/fs}
|
14
14
|
s.post_install_message = %q{=========================================================
|
15
15
|
FreeSWITCHeR
|
@@ -23,8 +23,8 @@ A ruby library for interacting with the "FreeSWITCH" (http://www.freeswitch.org)
|
|
23
23
|
|
24
24
|
REQUIREMENTS
|
25
25
|
------------
|
26
|
-
|
27
|
-
|
26
|
+
* ruby (>= 1.8)
|
27
|
+
* eventmachine (If you wish to use Outbound and Inbound listener)
|
28
28
|
|
29
29
|
USAGE
|
30
30
|
-----
|
@@ -35,97 +35,94 @@ An Outbound Event Listener Example that reads and returns DTMF input:
|
|
35
35
|
Simply just create a subclass of FSR::Listner::Outbound and all
|
36
36
|
new calls/sessions will invoke the "session_initiated" callback method.
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
class OutboundDemo < FSR::Listener::Outbound
|
46
|
-
|
47
|
-
def session_initiated
|
48
|
-
exten = @session.headers[:caller_caller_id_number]
|
49
|
-
FSR::Log.info "*** Answering incoming call from #{exten}"
|
50
|
-
|
51
|
-
answer do
|
52
|
-
FSR::Log.info "***Reading DTMF from #{exten}"
|
53
|
-
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do
|
54
|
-
FSR::Log.info "*** Updating session for #{exten}"
|
55
|
-
update_session do
|
56
|
-
FSR::Log.info "***Success, grabbed #{@session.headers[:variable_input].strip} from #{exten}"
|
57
|
-
hangup #Hangup the call
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
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. This is kicked off by "answer do"
|
39
|
+
|
40
|
+
#!/usr/bin/ruby
|
41
|
+
require 'fsr'
|
42
|
+
require 'fsr/listener/outbound'
|
43
|
+
|
44
|
+
class OutboundDemo < FSR::Listener::Outbound
|
61
45
|
|
46
|
+
def session_initiated
|
47
|
+
exten = @session.headers[:caller_caller_id_number]
|
48
|
+
FSR::Log.info "*** Answering incoming call from #{exten}"
|
49
|
+
|
50
|
+
answer do
|
51
|
+
FSR::Log.info "***Reading DTMF from #{exten}"
|
52
|
+
read("/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav", 4, 10, "input", 7000) do |read_var|
|
53
|
+
FSR::Log.info "***Success, grabbed #{read_var.strip} from #{exten}"
|
54
|
+
hangup #Hangup the call
|
55
|
+
end
|
62
56
|
end
|
63
57
|
|
64
58
|
end
|
65
59
|
|
66
|
-
|
60
|
+
end
|
67
61
|
|
62
|
+
FSR.start_oes! OutboundDemo, :port => 8084, :host => "127.0.0.1"
|
68
63
|
|
69
64
|
An Inbound Event Socket Listener example using FreeSWITCHeR's hook system:
|
70
65
|
--------------------------------------------------------------------------
|
71
66
|
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
#!/usr/bin/ruby
|
68
|
+
require 'pp'
|
69
|
+
require 'fsr'
|
70
|
+
require "fsr/listener/inbound"
|
75
71
|
|
76
|
-
|
77
|
-
|
78
|
-
|
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!" }
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
86
82
|
|
87
|
-
|
88
|
-
|
83
|
+
# This adds a hook for EXAMPLE 2
|
84
|
+
FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {|event| custom_channel_hangup_handler(event) }
|
89
85
|
|
90
86
|
|
91
|
-
|
92
|
-
|
87
|
+
# Start FSR Inbound Listener
|
88
|
+
FSR.start_ies!(FSL::Inbound, :host => "localhost", :port => 8021)
|
93
89
|
|
94
90
|
|
95
91
|
An Inbound Event Socket Listener example using the on_event callback method instead of hooks:
|
96
92
|
---------------------------------------------------------------------------------------------
|
97
93
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
94
|
+
#!/usr/bin/ruby
|
95
|
+
require 'pp'
|
96
|
+
require 'fsr'
|
97
|
+
require "fsr/listener/inbound"
|
102
98
|
|
103
|
-
class IesDemo < FSR::Listener::Inbound
|
104
99
|
|
105
|
-
|
106
|
-
pp event.headers
|
107
|
-
pp event.content[:event_name]
|
108
|
-
end
|
100
|
+
class IesDemo < FSR::Listener::Inbound
|
109
101
|
|
102
|
+
def on_event(event)
|
103
|
+
pp event.headers
|
104
|
+
pp event.content[:event_name]
|
110
105
|
end
|
111
106
|
|
112
|
-
|
107
|
+
end
|
108
|
+
|
109
|
+
FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021)
|
113
110
|
|
114
111
|
|
115
112
|
An example of using FSR::CommandSocket to originate a new call in irb:
|
116
113
|
----------------------------------------------------------------------
|
117
114
|
|
118
|
-
|
119
|
-
|
115
|
+
irb(main):001:0> require 'fsr'
|
116
|
+
=> true
|
120
117
|
|
121
|
-
|
122
|
-
|
118
|
+
irb(main):002:0> FSR.load_all_commands
|
119
|
+
=> [:sofia, :originate]
|
123
120
|
|
124
|
-
|
125
|
-
|
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">
|
126
123
|
|
127
|
-
|
128
|
-
|
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"}
|
129
126
|
|
130
127
|
|
131
128
|
|
@@ -138,7 +135,7 @@ Home page at http://code.rubyists.com/projects/fs
|
|
138
135
|
s.rubyforge_project = %q{freeswitcher}
|
139
136
|
s.rubygems_version = %q{1.3.1}
|
140
137
|
s.summary = %q{A library for interacting with the "FreeSWITCH":http://freeswitch.org telephony platform}
|
141
|
-
s.test_files = ["spec/fsr/app.rb", "spec/fsr/app/bridge.rb", "spec/fsr/app/conference.rb", "spec/fsr/app/fifo.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/listener.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
138
|
+
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/listener.rb", "spec/fsr/listener/inbound.rb", "spec/fsr/listener/outbound.rb", "spec/fsr/loading.rb"]
|
142
139
|
|
143
140
|
if s.respond_to? :specification_version then
|
144
141
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|