freeswitcher 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/License.txt +20 -0
- data/NEWS +3 -0
- data/README +85 -0
- data/Rakefile +82 -0
- data/bin/cmd_demo.rb +19 -0
- data/bin/ies_demo.rb +19 -0
- data/bin/ies_demo_with_hook.rb +27 -0
- data/bin/oes_demo.rb +22 -0
- data/bin/oes_demo2.rb +26 -0
- data/lib/fsr.rb +86 -0
- data/lib/fsr/app.rb +72 -0
- data/lib/fsr/app/answer.rb +21 -0
- data/lib/fsr/app/bridge.rb +33 -0
- data/lib/fsr/app/conference.rb +29 -0
- data/lib/fsr/app/fifo.rb +38 -0
- data/lib/fsr/app/fs_break.rb +21 -0
- data/lib/fsr/app/fs_sleep.rb +24 -0
- data/lib/fsr/app/hangup.rb +22 -0
- data/lib/fsr/app/log.rb +24 -0
- data/lib/fsr/app/playback.rb +23 -0
- data/lib/fsr/app/set.rb +22 -0
- data/lib/fsr/app/speak.rb +25 -0
- data/lib/fsr/app/transfer.rb +24 -0
- data/lib/fsr/cmd.rb +57 -0
- data/lib/fsr/cmd/fsctl.rb +41 -0
- data/lib/fsr/cmd/originate.rb +46 -0
- data/lib/fsr/cmd/sofia.rb +40 -0
- data/lib/fsr/cmd/sofia/profile.rb +75 -0
- data/lib/fsr/cmd/sofia/status.rb +39 -0
- data/lib/fsr/cmd/sofia_contact.rb +31 -0
- data/lib/fsr/cmd/status.rb +25 -0
- data/lib/fsr/command_socket.rb +29 -0
- data/lib/fsr/database.rb +7 -0
- data/lib/fsr/database/call_limit.rb +21 -0
- data/lib/fsr/database/core.rb +30 -0
- data/lib/fsr/database/sofia_reg_external.rb +0 -0
- data/lib/fsr/database/sofia_reg_internal.rb +0 -0
- data/lib/fsr/database/voicemail_default.rb +0 -0
- data/lib/fsr/event_socket.rb +41 -0
- data/lib/fsr/fake_socket.rb +68 -0
- data/lib/fsr/listener.rb +10 -0
- data/lib/fsr/listener/header_and_content_response.rb +21 -0
- data/lib/fsr/listener/inbound.rb +61 -0
- data/lib/fsr/listener/inbound/event.rb +42 -0
- data/lib/fsr/listener/outbound.rb +62 -0
- data/lib/fsr/listener/outbound.rb.orig +131 -0
- data/spec/fsr/app.rb +8 -0
- data/spec/fsr/app/bridge.rb +17 -0
- data/spec/fsr/app/conference.rb +12 -0
- data/spec/fsr/app/fifo.rb +29 -0
- data/spec/fsr/cmd.rb +8 -0
- data/spec/fsr/cmd/originate.rb +12 -0
- data/spec/fsr/cmd/sofia.rb +69 -0
- data/spec/fsr/cmd/sofia/profile.rb +58 -0
- data/spec/fsr/listener.rb +12 -0
- data/spec/fsr/listener/inbound.rb +19 -0
- data/spec/fsr/listener/outbound.rb +19 -0
- data/spec/fsr/loading.rb +27 -0
- data/spec/helper.rb +14 -0
- data/tasks/package.rake +29 -0
- data/tasks/ride.rake +6 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/spec.rake +59 -0
- metadata +229 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require "fsr/cmd"
|
3
|
+
FSR::Cmd.load_command("sofia")
|
4
|
+
|
5
|
+
describe "FSR::Cmd::Sofia::Profile" do
|
6
|
+
|
7
|
+
## Sofia profile ##
|
8
|
+
it "should allow FSR::Cmd::Sofia.new.profile (no arguments) through Sofia instance" do
|
9
|
+
sofia = FSR::Cmd::Sofia.new
|
10
|
+
profile = sofia.profile
|
11
|
+
profile.raw.should == "sofia profile"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should allow raw string as an argument through Sofia instance" do
|
15
|
+
sofia = FSR::Cmd::Sofia.new
|
16
|
+
profile = sofia.profile('internal stop')
|
17
|
+
profile.raw.should == "sofia profile internal stop"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should start a profile by name through Sofia instance" do
|
21
|
+
sofia = FSR::Cmd::Sofia.new
|
22
|
+
profile = sofia.profile.start('internal')
|
23
|
+
profile.raw.should == "sofia profile internal start"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should stop a profile by name through Sofia instance" do
|
27
|
+
sofia = FSR::Cmd::Sofia.new
|
28
|
+
profile = sofia.profile.stop('internal')
|
29
|
+
profile.raw.should == "sofia profile internal stop"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should restart a profile by name through Sofia instance" do
|
33
|
+
sofia = FSR::Cmd::Sofia.new
|
34
|
+
profile = sofia.profile.restart('internal')
|
35
|
+
profile.raw.should == "sofia profile internal restart"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should rescan a profile by name through Sofia instance" do
|
39
|
+
sofia = FSR::Cmd::Sofia.new
|
40
|
+
profile = sofia.profile.rescan('internal')
|
41
|
+
profile.raw.should == "sofia profile internal rescan"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should start, stop, rescan, restart a profile by name with a class method" do
|
45
|
+
# pass nil as the socket until we get the MockSocket completed
|
46
|
+
FSR::Cmd::Sofia::Profile.start("foo", nil).raw.should == "sofia profile foo start"
|
47
|
+
FSR::Cmd::Sofia::Profile.stop("foo", nil).raw.should == "sofia profile foo stop"
|
48
|
+
FSR::Cmd::Sofia::Profile.restart("foo", nil).raw.should == "sofia profile foo restart"
|
49
|
+
FSR::Cmd::Sofia::Profile.rescan("foo", nil).raw.should == "sofia profile foo rescan"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should allow instantiation directly, with hash options" do
|
53
|
+
# pass nil as the socket until we get the MockSocket completed
|
54
|
+
profile = FSR::Cmd::Sofia::Profile.new(nil, {:name => 'internal', :action => :stop})
|
55
|
+
profile.raw.should == "sofia profile internal stop"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec/helper"
|
2
|
+
require "fsr/listener"
|
3
|
+
describe "Basic FSR::Listener module" do
|
4
|
+
it "Aliases itself as FSL" do
|
5
|
+
FSL.should == FSR::Listener
|
6
|
+
end
|
7
|
+
|
8
|
+
it "Defines #receive_data" do
|
9
|
+
FSR::Listener.method_defined?(:receive_data).should == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require "fsr/listener/inbound"
|
3
|
+
|
4
|
+
# Bare class to use for testing
|
5
|
+
class MyListener < FSR::Listener::Inbound
|
6
|
+
end
|
7
|
+
|
8
|
+
# helper to instantiate a new MyListener
|
9
|
+
def my_listener
|
10
|
+
MyListener.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "Testing FSR::Listener::Inbound" do
|
14
|
+
|
15
|
+
it "defines #post_init" do
|
16
|
+
FSR::Listener::Inbound.method_defined?(:post_init).should == true
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require "fsr/listener/outbound"
|
3
|
+
|
4
|
+
# Bare class to use for testing
|
5
|
+
class MyListener < FSR::Listener::Outbound
|
6
|
+
end
|
7
|
+
|
8
|
+
# helper to instantiate a new MyListener
|
9
|
+
def my_listener
|
10
|
+
MyListener.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "Testing FSR::Listener::Outbound" do
|
14
|
+
|
15
|
+
it "defines #post_init" do
|
16
|
+
FSR::Listener::Outbound.method_defined?(:post_init).should == true
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/fsr/loading.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "Testing FSR module loading methods" do
|
5
|
+
# When you add applications you must modify the expected apps_loaded behavior
|
6
|
+
it "Loads all applications" do
|
7
|
+
all_apps = [:set, :transfer, :speak, :fs_sleep, :playback, :answer, :fifo, :bridge, :hangup, :conference, :fs_break, :log]
|
8
|
+
# Add any apps which will load to this set
|
9
|
+
apps_loaded = FSR.load_all_applications
|
10
|
+
apps_loaded.kind_of?(Array).should == true
|
11
|
+
all_apps.each do |app|
|
12
|
+
apps_loaded.delete(app).should == app
|
13
|
+
end
|
14
|
+
apps_loaded.size.should == 0
|
15
|
+
end
|
16
|
+
|
17
|
+
# When you add commands you must modify the expected cmds_loaded behavior
|
18
|
+
it "Loads all commands" do
|
19
|
+
all_commands = [:originate, :sofia, :fsctl, :sofia_contact, :status] # If you add a command add it to this set
|
20
|
+
cmds_loaded = FSR.load_all_commands
|
21
|
+
cmds_loaded.kind_of?(Array).should == true
|
22
|
+
all_commands.each do |cmd|
|
23
|
+
cmds_loaded.delete(cmd).should == cmd
|
24
|
+
end
|
25
|
+
cmds_loaded.size.should == 0
|
26
|
+
end
|
27
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'bacon'
|
3
|
+
rescue LoadError
|
4
|
+
puts <<-EOS
|
5
|
+
To run these tests you must install bacon.
|
6
|
+
Quick and easy install for gem:
|
7
|
+
gem install bacon
|
8
|
+
EOS
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
Bacon.summary_on_exit
|
13
|
+
|
14
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/fsr'))
|
data/tasks/package.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require 'rake'
|
3
|
+
require "lib/fsr"
|
4
|
+
namespace :pkg do
|
5
|
+
desc 'Build the gemspec'
|
6
|
+
task :build_gemspec do
|
7
|
+
require "erb"
|
8
|
+
unfiltered_files = Dir['**/*']
|
9
|
+
spec_files = unfiltered_files.reject do |filename|
|
10
|
+
filename.match(/^(?:spec|config|script|log|contrib)(?:\/|$)/) || File.basename(filename).match(/\.(?:gem|gemspec|swp|gemspec\.erb)$/) || File.basename(filename).match(/^(?:\.|RIDE)/)
|
11
|
+
end.inspect
|
12
|
+
|
13
|
+
spec_test_files = (["spec"] + Dir['spec/**/*']).inspect
|
14
|
+
spec_template = ERB.new(File.read("freeswitcher.gemspec.erb"))
|
15
|
+
version = FSR::VERSION
|
16
|
+
description = File.read("README")
|
17
|
+
File.open("freeswitcher.gemspec", "w+") { |specfile| specfile.puts spec_template.result(binding) }
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Make the gem'
|
22
|
+
task :gem => :build_gemspec do
|
23
|
+
output = %x{gem build freeswitcher.gemspec}
|
24
|
+
raise "Package did not build - #{output}" unless File.exists?("FreeSWITCHeR-#{FSR::VERSION}.gem")
|
25
|
+
puts output
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
data/tasks/ride.rake
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
desc 'Run all specs'
|
7
|
+
task :spec => :setup do
|
8
|
+
require 'open3'
|
9
|
+
|
10
|
+
specs = Dir['spec/fsr/**/*.rb']
|
11
|
+
# specs.delete_if{|f| f =~ /cache\/common\.rb/ }
|
12
|
+
|
13
|
+
some_failed = false
|
14
|
+
total = specs.size
|
15
|
+
len = specs.sort.last.size
|
16
|
+
left_format = "%4d/%d: %-#{len + 12}s"
|
17
|
+
red, green = "\e[31m%s\e[0m", "\e[32m%s\e[0m"
|
18
|
+
matcher = /(\d+) specifications \((\d+) requirements\), (\d+) failures, (\d+) errors/
|
19
|
+
tt = ta = tf = te = 0
|
20
|
+
|
21
|
+
specs.each_with_index do |spec, idx|
|
22
|
+
print(left_format % [idx + 1, total, spec])
|
23
|
+
unless RUBY_PLATFORM.include?("mswin32")
|
24
|
+
Open3.popen3("#{RUBY} -rubygems #{spec}") do |sin, sout, serr|
|
25
|
+
out = sout.read
|
26
|
+
err = serr.read
|
27
|
+
|
28
|
+
all = out.match(matcher).captures.map{|c| c.to_i }
|
29
|
+
tests, assertions, failures, errors = all
|
30
|
+
tt += tests; ta += assertions; tf += failures; te += errors
|
31
|
+
|
32
|
+
if tests == 0 || failures + errors > 0
|
33
|
+
some_failed = true
|
34
|
+
puts((red % "%5d tests, %d assertions, %d failures, %d errors") % all)
|
35
|
+
puts "", out, err, ""
|
36
|
+
else
|
37
|
+
puts((green % "%5d passed") % tests)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
out = %x{#{RUBY} -rubygems #{spec}}
|
42
|
+
error = ""
|
43
|
+
all = out.match(matcher).captures.map{|c| c.to_i }
|
44
|
+
tests, assertions, failures, errors = all
|
45
|
+
tt += tests; ta += assertions; tf += failures; te += errors
|
46
|
+
|
47
|
+
if tests == 0 || failures + errors > 0
|
48
|
+
some_failed = true
|
49
|
+
puts((red % "%5d tests, %d assertions, %d failures, %d errors") % all)
|
50
|
+
puts "", out, err, ""
|
51
|
+
else
|
52
|
+
puts((green % "%5d passed") % tests)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
puts "#{tt} specifications, (#{ta} requirements), #{tf} failures, #{te} errors"
|
58
|
+
exit 1 if some_failed
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: freeswitcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jayson Vaughn
|
8
|
+
- Michael Fellinger
|
9
|
+
- Kevin Berry
|
10
|
+
- TJ Vanderpoel
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2009-04-09 00:00:00 -05:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: eventmachine
|
20
|
+
type: :runtime
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: "0"
|
27
|
+
version:
|
28
|
+
description: "========================================================= FreeSWITCHeR Copyright (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry) Distributed under the terms of the MIT License. ========================================================== About ----- *** STILL UNDER HEAVY DEVELOPMENT *** A ruby library for interacting with the \"FreeSWITCH\" (http://www.freeswitch.org) opensource telephony platform *** STILL UNDER HEAVY DEVELOPMENT *** Requirements ------------ - ruby (>= 1.8) - eventmachine (If you wish to use Outbound and Inbound listener) Usage ----- Example of originating a new call in 'irb' using FSR::CommandSocket#originate: 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\"} Example of creating an Outbound Eventsocket listener: #!/usr/bin/env ruby require 'fsr' require \"fsr/listener/outbound\" class OesDemo < FSR::Listener::Outbound def session_initiated(session) number = session.headers[:caller_caller_id_number] # Grab the inbound caller id FSR::Log.info \"*** Answering incoming call from #{number}\" answer # Answer the call set \"hangup_after_bridge=true\" # Set a variable speak 'Hello, This is your phone switch. Have a great day' # use mod_flite to speak hangup # Hangup the call end end FSR.start_oes!(OesDemo, :port => 1888, :host => \"localhost\") Example of creating an Inbound Eventsocket listener: #!/usr/bin/env ruby 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) Support ------- Home page at http://code.rubyists.com/projects/fs #rubyists on FreeNode"
|
29
|
+
email: FreeSWITCHeR@rubyists.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- License.txt
|
38
|
+
- NEWS
|
39
|
+
- README
|
40
|
+
- Rakefile
|
41
|
+
- bin
|
42
|
+
- bin/cmd_demo.rb
|
43
|
+
- bin/ies_demo.rb
|
44
|
+
- bin/ies_demo_with_hook.rb
|
45
|
+
- bin/oes_demo.rb
|
46
|
+
- bin/oes_demo2.rb
|
47
|
+
- lib
|
48
|
+
- lib/fsr
|
49
|
+
- lib/fsr/app
|
50
|
+
- lib/fsr/app/answer.rb
|
51
|
+
- lib/fsr/app/bridge.rb
|
52
|
+
- lib/fsr/app/conference.rb
|
53
|
+
- lib/fsr/app/fifo.rb
|
54
|
+
- lib/fsr/app/fs_break.rb
|
55
|
+
- lib/fsr/app/fs_sleep.rb
|
56
|
+
- lib/fsr/app/hangup.rb
|
57
|
+
- lib/fsr/app/log.rb
|
58
|
+
- lib/fsr/app/playback.rb
|
59
|
+
- lib/fsr/app/set.rb
|
60
|
+
- lib/fsr/app/speak.rb
|
61
|
+
- lib/fsr/app/transfer.rb
|
62
|
+
- lib/fsr/app.rb
|
63
|
+
- lib/fsr/cmd
|
64
|
+
- lib/fsr/cmd/fsctl.rb
|
65
|
+
- lib/fsr/cmd/originate.rb
|
66
|
+
- lib/fsr/cmd/sofia
|
67
|
+
- lib/fsr/cmd/sofia/profile.rb
|
68
|
+
- lib/fsr/cmd/sofia/status.rb
|
69
|
+
- lib/fsr/cmd/sofia.rb
|
70
|
+
- lib/fsr/cmd/sofia_contact.rb
|
71
|
+
- lib/fsr/cmd/status.rb
|
72
|
+
- lib/fsr/cmd.rb
|
73
|
+
- lib/fsr/command_socket.rb
|
74
|
+
- lib/fsr/database
|
75
|
+
- lib/fsr/database/call_limit.rb
|
76
|
+
- lib/fsr/database/core.rb
|
77
|
+
- lib/fsr/database/sofia_reg_external.rb
|
78
|
+
- lib/fsr/database/sofia_reg_internal.rb
|
79
|
+
- lib/fsr/database/voicemail_default.rb
|
80
|
+
- lib/fsr/database.rb
|
81
|
+
- lib/fsr/event_socket.rb
|
82
|
+
- lib/fsr/fake_socket.rb
|
83
|
+
- lib/fsr/listener
|
84
|
+
- lib/fsr/listener/header_and_content_response.rb
|
85
|
+
- lib/fsr/listener/inbound
|
86
|
+
- lib/fsr/listener/inbound/event.rb
|
87
|
+
- lib/fsr/listener/inbound.rb
|
88
|
+
- lib/fsr/listener/outbound.rb
|
89
|
+
- lib/fsr/listener/outbound.rb.orig
|
90
|
+
- lib/fsr/listener.rb
|
91
|
+
- lib/fsr.rb
|
92
|
+
- tasks
|
93
|
+
- tasks/package.rake
|
94
|
+
- tasks/ride.rake
|
95
|
+
- tasks/rspec.rake
|
96
|
+
- tasks/spec.rake
|
97
|
+
- tmp
|
98
|
+
has_rdoc: false
|
99
|
+
homepage: http://code.rubyists.com/projects/fs
|
100
|
+
post_install_message: |
|
101
|
+
=========================================================
|
102
|
+
FreeSWITCHeR
|
103
|
+
Copyright (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry)
|
104
|
+
Distributed under the terms of the MIT License.
|
105
|
+
==========================================================
|
106
|
+
|
107
|
+
About
|
108
|
+
-----
|
109
|
+
*** STILL UNDER HEAVY DEVELOPMENT ***
|
110
|
+
|
111
|
+
A ruby library for interacting with the "FreeSWITCH" (http://www.freeswitch.org) opensource telephony platform
|
112
|
+
|
113
|
+
*** STILL UNDER HEAVY DEVELOPMENT ***
|
114
|
+
|
115
|
+
Requirements
|
116
|
+
------------
|
117
|
+
- ruby (>= 1.8)
|
118
|
+
- eventmachine (If you wish to use Outbound and Inbound listener)
|
119
|
+
|
120
|
+
Usage
|
121
|
+
-----
|
122
|
+
|
123
|
+
Example of originating a new call in 'irb' using FSR::CommandSocket#originate:
|
124
|
+
|
125
|
+
irb(main):001:0> require 'fsr'
|
126
|
+
=> true
|
127
|
+
|
128
|
+
irb(main):002:0> FSR.load_all_commands
|
129
|
+
=> [:sofia, :originate]
|
130
|
+
|
131
|
+
irb(main):003:0> sock = FSR::CommandSocket.new
|
132
|
+
=> #<FSR::CommandSocket:0xb7a89104 @server="127.0.0.1", @socket=#<TCPSocket:0xb7a8908c>, @port="8021", @auth="ClueCon">
|
133
|
+
|
134
|
+
irb(main):007:0> sock.originate(:target => 'sofia/gateway/carlos/8179395222', :endpoint => FSR::App::Bridge.new("user/bougyman")).run
|
135
|
+
=> {"Job-UUID"=>"732075a4-7dd5-4258-b124-6284a82a5ae7", "body"=>"", "Content-Type"=>"command/reply", "Reply-Text"=>"+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7"}
|
136
|
+
|
137
|
+
|
138
|
+
Example of creating an Outbound Eventsocket listener:
|
139
|
+
|
140
|
+
#!/usr/bin/env ruby
|
141
|
+
|
142
|
+
require 'fsr'
|
143
|
+
require "fsr/listener/outbound"
|
144
|
+
|
145
|
+
class OesDemo < FSR::Listener::Outbound
|
146
|
+
|
147
|
+
def session_initiated(session)
|
148
|
+
number = session.headers[:caller_caller_id_number] # Grab the inbound caller id
|
149
|
+
FSR::Log.info "*** Answering incoming call from #{number}"
|
150
|
+
answer # Answer the call
|
151
|
+
set "hangup_after_bridge=true" # Set a variable
|
152
|
+
speak 'Hello, This is your phone switch. Have a great day' # use mod_flite to speak
|
153
|
+
hangup # Hangup the call
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
FSR.start_oes!(OesDemo, :port => 1888, :host => "localhost")
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
Example of creating an Inbound Eventsocket listener:
|
163
|
+
|
164
|
+
#!/usr/bin/env ruby
|
165
|
+
|
166
|
+
require 'fsr'
|
167
|
+
require "fsr/listener/inbound"
|
168
|
+
|
169
|
+
class IesDemo < FSR::Listener::Inbound
|
170
|
+
|
171
|
+
def on_event(event)
|
172
|
+
pp event.headers
|
173
|
+
pp event.content[:event_name]
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021)
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
Support
|
183
|
+
-------
|
184
|
+
Home page at http://code.rubyists.com/projects/fs
|
185
|
+
#rubyists on FreeNode
|
186
|
+
|
187
|
+
rdoc_options: []
|
188
|
+
|
189
|
+
require_paths:
|
190
|
+
- lib
|
191
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: "0"
|
196
|
+
version:
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: "0"
|
202
|
+
version:
|
203
|
+
requirements: []
|
204
|
+
|
205
|
+
rubyforge_project:
|
206
|
+
rubygems_version: 1.3.1
|
207
|
+
signing_key:
|
208
|
+
specification_version: 2
|
209
|
+
summary: A library for interacting with the "FreeSWITCH":http://freeswitch.org telephony platform
|
210
|
+
test_files:
|
211
|
+
- spec
|
212
|
+
- spec/fsr
|
213
|
+
- spec/fsr/app
|
214
|
+
- spec/fsr/app/bridge.rb
|
215
|
+
- spec/fsr/app/conference.rb
|
216
|
+
- spec/fsr/app/fifo.rb
|
217
|
+
- spec/fsr/app.rb
|
218
|
+
- spec/fsr/cmd
|
219
|
+
- spec/fsr/cmd/originate.rb
|
220
|
+
- spec/fsr/cmd/sofia
|
221
|
+
- spec/fsr/cmd/sofia/profile.rb
|
222
|
+
- spec/fsr/cmd/sofia.rb
|
223
|
+
- spec/fsr/cmd.rb
|
224
|
+
- spec/fsr/listener
|
225
|
+
- spec/fsr/listener/inbound.rb
|
226
|
+
- spec/fsr/listener/outbound.rb
|
227
|
+
- spec/fsr/listener.rb
|
228
|
+
- spec/fsr/loading.rb
|
229
|
+
- spec/helper.rb
|