librevox 0.6 → 0.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.
- data/README.md +2 -2
- data/lib/librevox.rb +10 -6
- data/lib/librevox/listener/inbound.rb +12 -1
- data/librevox.gemspec +3 -3
- data/spec/librevox/listener/spec_inbound.rb +1 -0
- metadata +5 -4
data/README.md
CHANGED
@@ -183,8 +183,8 @@ the `Librevox::Commands` and `Librevox::Applications` modules.
|
|
183
183
|
|
184
184
|
## License
|
185
185
|
|
186
|
-
(c) 2009
|
187
|
-
(c) 2011
|
186
|
+
(c) 2009-2014 Harry Vangberg <harry@vangberg.name>
|
187
|
+
(c) 2011-2014 Firmafon ApS <info@firmafon.dk>
|
188
188
|
|
189
189
|
Librevox was inspired by and uses code from Freeswitcher, which is distributed
|
190
190
|
under the MIT license and (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel,
|
data/lib/librevox.rb
CHANGED
@@ -6,8 +6,6 @@ require 'librevox/listener/outbound'
|
|
6
6
|
require 'librevox/command_socket'
|
7
7
|
|
8
8
|
module Librevox
|
9
|
-
VERSION = "0.5"
|
10
|
-
|
11
9
|
def self.options
|
12
10
|
@options ||= {
|
13
11
|
:log_file => STDOUT,
|
@@ -25,6 +23,10 @@ module Librevox
|
|
25
23
|
logger
|
26
24
|
end
|
27
25
|
|
26
|
+
def self.reopen_log
|
27
|
+
@logger = logger!
|
28
|
+
end
|
29
|
+
|
28
30
|
# When called without a block, it will start the listener that is passed as
|
29
31
|
# first argument:
|
30
32
|
#
|
@@ -42,19 +44,21 @@ module Librevox
|
|
42
44
|
EM.run do
|
43
45
|
trap("TERM") {stop}
|
44
46
|
trap("INT") {stop}
|
47
|
+
trap("HUP") {reopen_log}
|
45
48
|
|
46
49
|
block_given? ? instance_eval(&block) : run(klass, args)
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
53
|
def self.run klass, args={}
|
51
|
-
|
52
|
-
port = args.delete(:port)
|
54
|
+
args[:host] ||= "localhost"
|
53
55
|
|
54
56
|
if klass.ancestors.include? Librevox::Listener::Inbound
|
55
|
-
|
57
|
+
args[:port] ||= 8021
|
58
|
+
EM.connect args[:host], args[:port], klass, args
|
56
59
|
elsif klass.ancestors.include? Librevox::Listener::Outbound
|
57
|
-
|
60
|
+
args[:port] ||= 8084
|
61
|
+
EM.start_server host, args[:port], klass, args
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
@@ -7,13 +7,24 @@ module Librevox
|
|
7
7
|
super
|
8
8
|
|
9
9
|
@auth = args[:auth] || "ClueCon"
|
10
|
+
@host, @port = args.values_at(:host, :port)
|
11
|
+
|
12
|
+
EventMachine.add_shutdown_hook {@shutdown = true}
|
10
13
|
end
|
11
14
|
|
12
|
-
def
|
15
|
+
def connection_completed
|
16
|
+
Librevox.logger.info "Connected."
|
13
17
|
super
|
14
18
|
send_data "auth #{@auth}\n\n"
|
15
19
|
send_data "event plain ALL\n\n"
|
16
20
|
end
|
21
|
+
|
22
|
+
def unbind
|
23
|
+
if !@shutdown
|
24
|
+
Librevox.logger.error "Lost connection. Reconnecting in 1 second."
|
25
|
+
EM.add_timer(1) {reconnect(@host, @port.to_i)}
|
26
|
+
end
|
27
|
+
end
|
17
28
|
end
|
18
29
|
end
|
19
30
|
end
|
data/librevox.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "librevox"
|
3
|
-
s.version = "0.
|
4
|
-
s.date = "
|
3
|
+
s.version = "0.7"
|
4
|
+
s.date = "2014-01-15"
|
5
5
|
s.summary = "Ruby library for interacting with FreeSWITCH."
|
6
6
|
s.email = "harry@vangberg.name"
|
7
7
|
s.homepage = "http://github.com/vangberg/librevox"
|
@@ -33,5 +33,5 @@ open source telephony platform FreeSwitch."
|
|
33
33
|
"spec/librevox/listener/spec_inbound.rb",
|
34
34
|
"spec/librevox/listener/spec_outbound.rb"
|
35
35
|
]
|
36
|
-
s.add_dependency "eventmachine", ">= 0.
|
36
|
+
s.add_dependency "eventmachine", ">= 1.0.0"
|
37
37
|
end
|
@@ -15,6 +15,7 @@ describe "Inbound listener" do
|
|
15
15
|
behaves_like "api commands"
|
16
16
|
|
17
17
|
should "authorize and subscribe to events" do
|
18
|
+
@listener.connection_completed
|
18
19
|
@listener.outgoing_data.shift.should == "auth ClueCon\n\n"
|
19
20
|
@listener.outgoing_data.shift.should == "event plain ALL\n\n"
|
20
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librevox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.7'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 1.0.0
|
30
30
|
description: ! 'EventMachine-based Ruby library for interacting with the
|
31
31
|
|
32
32
|
open source telephony platform FreeSwitch.'
|
@@ -87,3 +87,4 @@ test_files:
|
|
87
87
|
- spec/librevox/spec_response.rb
|
88
88
|
- spec/librevox/listener/spec_inbound.rb
|
89
89
|
- spec/librevox/listener/spec_outbound.rb
|
90
|
+
has_rdoc:
|