freeswitcher 0.6.6 → 0.6.7

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.
@@ -0,0 +1,63 @@
1
+ require "fsr/cmd"
2
+ module FSR
3
+ module Cmd
4
+ class Conference < Command
5
+ attr_reader :fs_socket, :conference_name, :profile, :pin, :flags, :action, :target, :target_options, :digits
6
+ def initialize(fs_socket = nil, args = {})
7
+ raise(ArgumentError, "args (Passed: <<<#{args}>>>) must be a hash") unless args.kind_of?(Hash)
8
+ @conference_name, @pin, @profile, @flags = args.values_at(:conference_name, :pin, :profile, :flags)
9
+ @action, @target, @target_options = args.values_at(:action, :target, :target_options)
10
+ @digits = args[:digits]
11
+ @fs_socket = fs_socket
12
+ raise(ArgumentError, "Cannot use conference without :conference_name") unless @conference_name
13
+ case @action
14
+ when :dial
15
+ raise(ArgumentError, "Cannot dial without :target") unless @target
16
+ if @target_options
17
+ raise(ArgumentError, ":target_options must be a hash if :target_options is set") unless @orginate_options.kind_of?(Hash)
18
+ end
19
+ when :dtmf
20
+ raise(ArgumentError, "Cannot send dtmf without :target") unless @target
21
+ raise(ArgumentError, "Cannot send dtmf without :digits") unless @digits
22
+ when :kick
23
+ raise(ArgumentError, "Cannot kick without :target") unless @target
24
+ else
25
+ # go with flow, mate
26
+ end
27
+ end
28
+
29
+ # Send the command to the event socket, using bgapi by default.
30
+ def run(api_method = :bgapi)
31
+ conf_command = "%s %s" % [api_method, raw]
32
+ Log.debug "saying #{conf_command}"
33
+ @fs_socket.say(conf_command)
34
+ end
35
+
36
+ def arguments
37
+ target_options = target_options.keys.sort { |a,b| a.to_s <=> b.to_s }.map { |k| "%s=%s" % [k, orginate_options[k]] }.join(",") if target_options
38
+ conference_name << "@#{profile}" if profile
39
+ if pin
40
+ conference_name << "+#{pin}"
41
+ conference_name << "+#{flags}" if flags
42
+ end
43
+ args = [conference_name]
44
+ args << action if action
45
+
46
+ if target
47
+ @target = "{#{target_options}}#{target}" if target_options
48
+ args << target
49
+ end
50
+
51
+ args << digits if action == :dtmf
52
+ args.compact
53
+ end
54
+
55
+ def raw
56
+ ["conference", *arguments].join(" ")
57
+ end
58
+
59
+ end
60
+
61
+ register(:conference, Conference)
62
+ end
63
+ end
@@ -59,6 +59,7 @@ module FSR
59
59
  def authorize_and_register_for_events
60
60
  FSR::Log.info "Connection established. Authorizing..."
61
61
  say("auth #{@auth}")
62
+ FSR::Log.info "#{@host} Connected."
62
63
  before_session
63
64
  end
64
65
 
data/lib/fsr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FSR
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
@@ -0,0 +1,55 @@
1
+ require 'spec/helper'
2
+ require "fsr/cmd"
3
+ FSR::Cmd.load_command("conference")
4
+
5
+ describe "Testing FSR::Cmd::Conference" do
6
+ it "Cannot use conference without :conference_name" do
7
+ lambda { FSR::Cmd::Conference.new(nil) }.should.raise(ArgumentError).
8
+ message.should.match(/Cannot use conference without :conference_name/)
9
+ end
10
+
11
+ it "Cannot dial without :target" do
12
+ lambda { FSR::Cmd::Conference.new(nil, :conference_name => 1001, :action => :dial) }.should.raise(ArgumentError).
13
+ message.should.match(/Cannot dial without :target/)
14
+ end
15
+
16
+ it "Cannot send dtmf without :target" do
17
+ lambda { FSR::Cmd::Conference.new(nil, :conference_name => 1001, :action => :dtmf) }.should.raise(ArgumentError).
18
+ message.should.match(/Cannot send dtmf without :target/)
19
+ end
20
+
21
+ it "Cannot send dtmf without :digits" do
22
+ lambda { FSR::Cmd::Conference.new(nil, :conference_name => 1001, :action => :dtmf, :target => 1) }.should.raise(ArgumentError).
23
+ message.should.match(/Cannot send dtmf without :digits/)
24
+ end
25
+
26
+ it "Cannot send kick without :target" do
27
+ lambda { FSR::Cmd::Conference.new(nil, :conference_name => 1001, :action => :kick) }.should.raise(ArgumentError).
28
+ message.should.match(/Cannot kick without :target/)
29
+ end
30
+
31
+ it "Puts callee into conference" do
32
+ conference = FSR::Cmd::Conference.new(nil, :conference_name => 1001, :action => :dial, :target => "user/1000")
33
+ conference.raw.should == "conference 1001 dial user/1000"
34
+ end
35
+
36
+ it "Kicks member out of conference" do
37
+ conference = FSR::Cmd::Conference.new(nil, :conference_name => "1001", :action => :kick, :target => 1)
38
+ conference.raw.should == "conference 1001 kick 1"
39
+ end
40
+
41
+ it "Sends dtmf digits to a member" do
42
+ conference = FSR::Cmd::Conference.new(nil, :conference_name => "1001", :action => :dtmf, :target => 1, :digits => 134)
43
+ conference.raw.should == "conference 1001 dtmf 1 134"
44
+ end
45
+
46
+ it "Sends dtmf digits to all members" do
47
+ conference = FSR::Cmd::Conference.new(nil, :conference_name => "1001", :action => :dtmf, :target => "all", :digits => 134)
48
+ conference.raw.should == "conference 1001 dtmf all 134"
49
+ end
50
+
51
+ it "Sends dtmf digits to last member" do
52
+ conference = FSR::Cmd::Conference.new(nil, :conference_name => "1001", :action => :dtmf, :target => "last", :digits => 134)
53
+ conference.raw.should == "conference 1001 dtmf last 134"
54
+ end
55
+ end
data/spec/fsr/loading.rb CHANGED
@@ -16,7 +16,7 @@ describe "Testing FSR module loading methods" do
16
16
 
17
17
  # When you add commands you must modify the expected cmds_loaded behavior
18
18
  it "Loads all commands" do
19
- all_commands = [:uuid_dump, :originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :call_center, :channels, :enum, :sched_hangup, :sched_transfer, :uuid_transfer, :uuid_send_dtmf] # If you add a command add it to this set
19
+ all_commands = [:uuid_dump, :originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :call_center, :channels, :enum, :sched_hangup, :sched_transfer, :uuid_transfer, :uuid_send_dtmf, :conference] # If you add a command add it to this set
20
20
  cmds_loaded = FSR.load_all_commands
21
21
  cmds_loaded.kind_of?(Array).should == true
22
22
  all_commands.each do |cmd|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 6
9
- version: 0.6.6
8
+ - 7
9
+ version: 0.6.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jayson Vaughn
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-03-05 00:00:00 -06:00
20
+ date: 2011-03-09 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,7 @@ files:
85
85
  - lib/fsr/cmd/call_center.rb
86
86
  - lib/fsr/cmd/calls.rb
87
87
  - lib/fsr/cmd/channels.rb
88
+ - lib/fsr/cmd/conference.rb
88
89
  - lib/fsr/cmd/enum.rb
89
90
  - lib/fsr/cmd/fsctl.rb
90
91
  - lib/fsr/cmd/originate.rb
@@ -162,6 +163,7 @@ files:
162
163
  - spec/fsr/cmd/call_center.rb
163
164
  - spec/fsr/cmd/calls.rb
164
165
  - spec/fsr/cmd/channels.rb
166
+ - spec/fsr/cmd/conference.rb
165
167
  - spec/fsr/cmd/enum.rb
166
168
  - spec/fsr/cmd/originate.rb
167
169
  - spec/fsr/cmd/sched_hangup.rb
@@ -415,6 +417,7 @@ test_files:
415
417
  - spec/fsr/cmd/call_center.rb
416
418
  - spec/fsr/cmd/calls.rb
417
419
  - spec/fsr/cmd/channels.rb
420
+ - spec/fsr/cmd/conference.rb
418
421
  - spec/fsr/cmd/enum.rb
419
422
  - spec/fsr/cmd/originate.rb
420
423
  - spec/fsr/cmd/sched_hangup.rb