ruby_rabbitmq_janus 1.0.6 → 1.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.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/lib/rrj/info.rb +1 -1
- data/lib/rrj/init.rb +5 -2
- data/lib/rrj/janus/responses/response.rb +4 -4
- data/lib/rrj/janus/transactions/admin.rb +20 -6
- data/lib/rrj/janus/transactions/handle.rb +31 -1
- data/lib/rrj/janus/transactions/session.rb +1 -1
- data/lib/rrj/janus/transactions/transaction.rb +20 -12
- data/lib/rrj/rabbit/publish/admin.rb +6 -0
- data/lib/rrj/rabbit/publish/base_publisher.rb +1 -1
- data/lib/rrj/rabbit/publish/exclusive.rb +6 -1
- data/lib/rrj/rabbit/publish/non_exclusive.rb +4 -1
- data/lib/rrj/rabbit/publish/publisher.rb +1 -2
- data/lib/rrj/tools/replaces_admin.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b347623ca38c99dcc403e14e1d0508ddd931d225
|
4
|
+
data.tar.gz: cf5d65fb6489a305c7ba933eec933ffdff2faa21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e72b12fba3edea0af23521c9cfcdbbc57de4589841cc8c5c34c15c70e91de314a8e9a9daa26098f71aecba014dd5950b5e01cecc20adf1aef77cee053d3cfc3
|
7
|
+
data.tar.gz: ecac69d94e67405f13dbe5329280b1a9cbf06fcf9271ad03ced2cc4e69511bb26eec58e20c9ed87161e1768133d33be005cb0eb53b189e785d68ae818cf1a640
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--format
|
1
|
+
--format documentation
|
2
2
|
--color
|
data/lib/rrj/info.rb
CHANGED
data/lib/rrj/init.rb
CHANGED
@@ -35,7 +35,10 @@ module RubyRabbitmqJanus
|
|
35
35
|
# Given a type to request. JSON request writing in 'config/requests/'
|
36
36
|
# @param [Bollean] exclusive
|
37
37
|
# Use an exclusive queue or not
|
38
|
-
# @example Sending an message info
|
38
|
+
# @example Sending an message info in queue 'to-janus'
|
39
|
+
# RubyRabbitmqJanus::RRJ.new.message_simple('base::info', true)
|
40
|
+
# #=> {}
|
41
|
+
# @example Sending an message info in queue exclusive 'ampq.gen-xxxxx'
|
39
42
|
# RubyRabbitmqJanus::RRJ.new.message_simple('base::info')
|
40
43
|
# #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
|
41
44
|
# @return [RubyRabbitmqJanus::Janus::Responses::Standard]
|
@@ -57,7 +60,7 @@ module RubyRabbitmqJanus
|
|
57
60
|
# #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
|
58
61
|
# @return [RubyRabbitmqJanus::Janus::Responses::Standard]
|
59
62
|
# Give an object response to janus server
|
60
|
-
def message_session(type, options = {}, exclusive =
|
63
|
+
def message_session(type, options = {}, exclusive = true)
|
61
64
|
Janus::Transactions::Session.new(@session).session_connect(exclusive) do
|
62
65
|
Janus::Messages::Standard.new(type, use_current_session?(options))
|
63
66
|
end
|
@@ -12,7 +12,7 @@ module RubyRabbitmqJanus
|
|
12
12
|
def initialize(response_janus)
|
13
13
|
@request = response_janus
|
14
14
|
rescue => error
|
15
|
-
Tools::Log.instance.debug "Request error : #{@request}"
|
15
|
+
Tools::Log.instance.debug "Request error [initialize] : #{@request}"
|
16
16
|
raise Errors::JanusResponseInit, error
|
17
17
|
else
|
18
18
|
Tools::Log.instance.debug "Response return : #{to_json}"
|
@@ -23,7 +23,7 @@ module RubyRabbitmqJanus
|
|
23
23
|
analysis
|
24
24
|
@request.to_json
|
25
25
|
rescue => error
|
26
|
-
Tools::Log.instance.debug "Request error : #{@request}"
|
26
|
+
Tools::Log.instance.debug "Request error [to_json] : #{@request}"
|
27
27
|
raise Errors::JanusResponseJson, [error, @request]
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ module RubyRabbitmqJanus
|
|
31
31
|
def to_nice_json
|
32
32
|
JSON.pretty_generate to_hash
|
33
33
|
rescue => error
|
34
|
-
Tools::Log.instance.debug "Request error : #{@request}"
|
34
|
+
Tools::Log.instance.debug "Request error [to_nice_json] : #{@request}"
|
35
35
|
raise Errors::JanusResponsePrettyJson, error
|
36
36
|
end
|
37
37
|
|
@@ -40,7 +40,7 @@ module RubyRabbitmqJanus
|
|
40
40
|
analysis
|
41
41
|
@request
|
42
42
|
rescue => error
|
43
|
-
Tools::Log.instance.debug "Request error : #{@request}"
|
43
|
+
Tools::Log.instance.debug "Request error [to_hash] : #{@request}"
|
44
44
|
raise Errors::JanusResponseHash, [error, @request]
|
45
45
|
end
|
46
46
|
|
@@ -25,20 +25,34 @@ module RubyRabbitmqJanus
|
|
25
25
|
|
26
26
|
# Publish an message in handle
|
27
27
|
def publish_message_handle(type, options = {})
|
28
|
-
opts = {
|
29
|
-
|
30
|
-
|
28
|
+
opts = {
|
29
|
+
'session_id' => session,
|
30
|
+
'handle_id' => handle,
|
31
|
+
'add' => {
|
32
|
+
'admin_secret' => Tools::Config.instance.options['rabbit']['admin_pass']
|
33
|
+
}
|
34
|
+
}
|
35
|
+
msg = Janus::Messages::Admin.new(type, opts.merge!(options))
|
36
|
+
send_a_message { msg }
|
31
37
|
end
|
32
38
|
|
33
39
|
# Stop an handle running
|
34
40
|
def handle_running_stop
|
35
|
-
|
36
|
-
publish_message_handle('base::detach', admin_secret: secret)
|
41
|
+
publish_message_handle('base::detach')
|
37
42
|
end
|
38
43
|
|
39
44
|
# Define queue used for admin message
|
40
45
|
def choose_queue
|
41
|
-
|
46
|
+
chan = rabbit.channel
|
47
|
+
@publish = Rabbit::Publisher::PublisherAdmin.new(chan)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Override method for publishing an message and reading a response
|
53
|
+
def send_a_message
|
54
|
+
Tools::Log.instance.info 'Publish a message ...'
|
55
|
+
Janus::Responses::Standard.new(publish.send_a_message(yield))
|
42
56
|
end
|
43
57
|
end
|
44
58
|
end
|
@@ -6,8 +6,15 @@ module RubyRabbitmqJanus
|
|
6
6
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
7
7
|
# This class work with janus and send a series of message
|
8
8
|
class Handle < Session
|
9
|
+
# Inistialize transaction handle
|
10
|
+
def initialize(session)
|
11
|
+
super(session)
|
12
|
+
@exclusive = nil
|
13
|
+
end
|
14
|
+
|
9
15
|
# Initialize connection to Rabbit and Janus
|
10
16
|
def handle_connect(exclusive)
|
17
|
+
@exclusive = exclusive
|
11
18
|
rabbit.transaction_long do
|
12
19
|
choose_queue(exclusive)
|
13
20
|
create_handle
|
@@ -18,6 +25,7 @@ module RubyRabbitmqJanus
|
|
18
25
|
# Initialize connection to Rabbit and Janus and close after sending an received
|
19
26
|
# a response
|
20
27
|
def handle_connect_and_stop(exclusive)
|
28
|
+
@exclusive = exclusive
|
21
29
|
rabbit.transaction_short do
|
22
30
|
choose_queue(exclusive)
|
23
31
|
create_handle
|
@@ -34,7 +42,29 @@ module RubyRabbitmqJanus
|
|
34
42
|
def publish_message_handle(type, options = {})
|
35
43
|
opts = { 'session_id' => session, 'handle_id' => handle }
|
36
44
|
msg = Janus::Messages::Standard.new(type, opts.merge!(options))
|
37
|
-
|
45
|
+
publisher = publish.send_a_message(msg)
|
46
|
+
Janus::Responses::Standard.new(read_response(publisher, @exclusive))
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Associate handle to transaction
|
52
|
+
def create_handle
|
53
|
+
Tools::Log.instance.info 'Create an handle'
|
54
|
+
msg = Janus::Messages::Standard.new('base::attach', 'session_id' => session)
|
55
|
+
@handle = send_a_message_exclusive { msg }
|
56
|
+
end
|
57
|
+
|
58
|
+
# Send a messaeg in exclusive queue
|
59
|
+
def send_a_message_exclusive
|
60
|
+
Janus::Responses::Standard.new(read_response_exclusive { yield }).sender
|
61
|
+
end
|
62
|
+
|
63
|
+
# Read an response in queue exclusive
|
64
|
+
def read_response_exclusive
|
65
|
+
chan = rabbit.channel
|
66
|
+
tmp_publish = Rabbit::Publisher::PublishExclusive.new(chan, '')
|
67
|
+
tmp_publish.send_a_message(yield)
|
38
68
|
end
|
39
69
|
end
|
40
70
|
end
|
@@ -21,7 +21,7 @@ module RubyRabbitmqJanus
|
|
21
21
|
def connect(exclusive)
|
22
22
|
@rabbit.transaction_short do
|
23
23
|
choose_queue(exclusive)
|
24
|
-
send_a_message { yield }
|
24
|
+
send_a_message(exclusive) { yield }
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,28 +31,36 @@ module RubyRabbitmqJanus
|
|
31
31
|
|
32
32
|
# determine queue used
|
33
33
|
# :reek:ControlParameter and :reek:BooleanParameter
|
34
|
-
def choose_queue(exclusive
|
34
|
+
def choose_queue(exclusive)
|
35
35
|
chan = @rabbit.channel
|
36
36
|
@publish = if exclusive
|
37
|
-
Tools::Log.instance.debug \
|
38
|
-
'Choose an queue non Exclusive : to-janus'
|
39
|
-
Rabbit::Publisher::PublishNonExclusive.new(chan)
|
40
|
-
else
|
41
37
|
Tools::Log.instance.debug \
|
42
38
|
'Choose an queue Exclusive : ampq.gen-xxx'
|
43
39
|
Rabbit::Publisher::PublishExclusive.new(chan, '')
|
40
|
+
else
|
41
|
+
Tools::Log.instance.debug \
|
42
|
+
'Choose an queue non Exclusive : to-janus'
|
43
|
+
Rabbit::Publisher::PublishNonExclusive.new(chan)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
# Send a message to queue
|
48
|
-
def send_a_message
|
49
|
-
|
48
|
+
def send_a_message(exclusive)
|
49
|
+
Tools::Log.instance.info 'Publish a message ...'
|
50
|
+
publish = @publish.send_a_message(yield)
|
51
|
+
Janus::Responses::Standard.new(read_response(publish, exclusive))
|
50
52
|
end
|
51
53
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
# Read a response if is a exclusive message
|
55
|
+
# :reek:ControlParameter
|
56
|
+
def read_response(publish, exclusive)
|
57
|
+
if exclusive
|
58
|
+
Tools::Log.instance.info '... and read a janus response'
|
59
|
+
publish
|
60
|
+
else
|
61
|
+
Tools::Log.instance.info '... and return an empty response'
|
62
|
+
{}
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
58
66
|
end
|
@@ -23,8 +23,8 @@ module RubyRabbitmqJanus
|
|
23
23
|
|
24
24
|
# return an response when signal is trigger
|
25
25
|
def return_response
|
26
|
-
Tools::Log.instance.debug 'Response received'
|
27
26
|
@lock.synchronize do
|
27
|
+
Tools::Log.instance.debug 'Response received'
|
28
28
|
@condition.wait(@lock)
|
29
29
|
@response
|
30
30
|
end
|
@@ -9,7 +9,12 @@ module RubyRabbitmqJanus
|
|
9
9
|
def initialize(exchange, name_queue)
|
10
10
|
@reply = exchange.queue(name_queue, exclusive: true)
|
11
11
|
super(exchange)
|
12
|
-
|
12
|
+
subscribe_to_queue
|
13
|
+
end
|
14
|
+
|
15
|
+
def send_a_message(request)
|
16
|
+
super(request)
|
17
|
+
return_response
|
13
18
|
end
|
14
19
|
|
15
20
|
private
|
@@ -11,7 +11,10 @@ module RubyRabbitmqJanus
|
|
11
11
|
def initialize(exchange)
|
12
12
|
@reply = exchange.queue(queue_from)
|
13
13
|
super(exchange)
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def send_a_message(request)
|
17
|
+
super(request)
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
@@ -11,7 +11,7 @@ module RubyRabbitmqJanus
|
|
11
11
|
super()
|
12
12
|
@exchange = exchange.default_exchange
|
13
13
|
@message = nil
|
14
|
-
|
14
|
+
Tools::Log.instance.info "Create/Connect to queue -- #{reply.name}"
|
15
15
|
end
|
16
16
|
|
17
17
|
# Publish an message in queue
|
@@ -20,7 +20,6 @@ module RubyRabbitmqJanus
|
|
20
20
|
@message = request
|
21
21
|
@exchange.publish(@message.to_json,
|
22
22
|
request.options.merge!(reply_to: queue_name))
|
23
|
-
return_response
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
@@ -11,6 +11,14 @@ module RubyRabbitmqJanus
|
|
11
11
|
def replace_classic
|
12
12
|
super
|
13
13
|
replace_admins if request.key?('admin_secret')
|
14
|
+
add_secret if opts.key?('add')
|
15
|
+
end
|
16
|
+
|
17
|
+
# Add string secret for admin request
|
18
|
+
def add_secret
|
19
|
+
values = opts['add']
|
20
|
+
Tools::Log.instance.debug "Values add : #{values}"
|
21
|
+
request.merge!(values)
|
14
22
|
end
|
15
23
|
|
16
24
|
# Replace elements admins if present
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_rabbitmq_janus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VAILLANT Jeremy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|