freeswitcher 0.6.17 → 0.6.18
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/lib/fsr/cmd/channels.rb +18 -11
- data/lib/fsr/version.rb +1 -1
- data/spec/fsr/cmd/channels.rb +2 -2
- metadata +1 -1
data/lib/fsr/cmd/channels.rb
CHANGED
@@ -13,7 +13,7 @@ module FSR
|
|
13
13
|
|
14
14
|
def initialize(fs_socket = nil, filter = nil)
|
15
15
|
@filter = filter
|
16
|
-
@filter = nil if
|
16
|
+
@filter = nil if @filter === false
|
17
17
|
@fs_socket = fs_socket # FSR::CommandSocket obj
|
18
18
|
end
|
19
19
|
|
@@ -22,21 +22,28 @@ module FSR
|
|
22
22
|
orig_command = "%s %s" % [api_method, raw]
|
23
23
|
Log.debug "saying #{orig_command}"
|
24
24
|
resp = @fs_socket.say(orig_command)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
if resp["body"] =~ /USAGE/
|
26
|
+
Log.warn "This server does not support #{raw}, trying Calls"
|
27
|
+
return Calls.new(@fs_socket, :detailed).run
|
28
|
+
else
|
29
|
+
unless resp["body"] == "0 total."
|
30
|
+
call_info, count = resp["body"].split("\n\n")
|
31
|
+
require "fsr/model/channel"
|
32
|
+
require "csv"
|
33
|
+
channels = CSV.parse(call_info)
|
34
|
+
headers = channels[0]
|
35
|
+
@channels = channels[1 .. -1].map { |c| FSR::Model::Channel.new(headers ,*c) }
|
36
|
+
return @channels
|
37
|
+
end
|
38
|
+
[]
|
33
39
|
end
|
34
|
-
[]
|
35
40
|
end
|
36
41
|
|
37
42
|
# This method builds the API command to send to the freeswitch event socket
|
38
43
|
def raw
|
39
|
-
if @filter
|
44
|
+
if @filter === true
|
45
|
+
'show distinct_channels'
|
46
|
+
elsif @filter.nil?
|
40
47
|
'show channels'
|
41
48
|
elsif @filter.is_a?(Fixnum)
|
42
49
|
'show channels %d' % @filter
|
data/lib/fsr/version.rb
CHANGED
data/spec/fsr/cmd/channels.rb
CHANGED
@@ -13,8 +13,8 @@ describe "Testing FSR::Cmd::Channels" do
|
|
13
13
|
|
14
14
|
it "FSR::Cmd::Channels (true as the filter) should send show channels" do
|
15
15
|
sofia = FSR::Cmd::Channels.new(nil, true)
|
16
|
-
sofia.raw.should == "show
|
17
|
-
sofia.instance_variable_get("@filter").should
|
16
|
+
sofia.raw.should == "show distinct_channels"
|
17
|
+
sofia.instance_variable_get("@filter").should === true
|
18
18
|
end
|
19
19
|
|
20
20
|
it "FSR::Cmd::Channels (string as the filter) should add the filter" do
|