ruby_rabbitmq_janus 2.0.0.pre.101 → 2.0.0.pre.106
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/lib/generators/ruby_rabbitmq_janus/initializer_generator.rb +14 -14
- data/lib/generators/ruby_rabbitmq_janus/install_generator.rb +16 -16
- data/lib/rrj/errors/init.rb +1 -0
- data/lib/rrj/errors/janus/janus.rb +1 -0
- data/lib/rrj/info.rb +6 -5
- data/lib/rrj/rabbit/publish/base_publisher.rb +10 -7
- data/lib/rrj/rabbit/publish/listener.rb +16 -6
- data/lib/rrj/rabbit/publish/publisher.rb +21 -3
- data/spec/request/peer/request_offer_spec.rb +13 -13
- data/spec/rrj/rabbit/publish/base_publisher_spec.rb +1 -1
- data/spec/support/examples_message.rb +2 -0
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cffbdeffff5f2b89552255ef1b160e416c6ca0f
|
4
|
+
data.tar.gz: d55adf89593d268bad4253c82a0c5fb3cfaa56a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5244dfe48d06b33c1f5f712e3f41418e1e2e7b025f5ca7e19f134f5af3459e42eca201aad512ff607bb987a11d402eae9973cd9116a21c63e4a04147b4e493d6
|
7
|
+
data.tar.gz: 2b43484d9818339b2aad0a0cdf8568466272aca213d69870079ce194eecafc0f07ac84a231f04024599b13739cae7dd1986546efc5dbfbe712e5953ccbc298d8
|
@@ -6,25 +6,25 @@ module RubyRabbitmqJanus
|
|
6
6
|
class InitializerGenerator < Rails::Generators::Base
|
7
7
|
desc 'Generate a initializer to this gem for rails application.'
|
8
8
|
INITIALIZER = <<-INIT
|
9
|
-
# frozen_string_literal: true
|
9
|
+
# frozen_string_literal: true
|
10
10
|
|
11
|
-
require 'actions'
|
11
|
+
require 'actions'
|
12
12
|
|
13
|
-
# Initialize a gem and create an session with a keepalive
|
14
|
-
::RRJ = RubyRabbitmqJanus::RRJ.new
|
13
|
+
# Initialize a gem and create an session with a keepalive
|
14
|
+
::RRJ = RubyRabbitmqJanus::RRJ.new
|
15
15
|
|
16
|
-
# For admin management
|
17
|
-
# ::RRJ = RubyRabbitmqJanus::RRJAdmin.new
|
16
|
+
# For admin management
|
17
|
+
# ::RRJ = RubyRabbitmqJanus::RRJAdmin.new
|
18
18
|
|
19
|
-
# This test disable this gems execution when you running an task with rake
|
20
|
-
unless File.basename($PROGRAM_NAME) == 'rake'
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
# This test disable this gems execution when you running an task with rake
|
20
|
+
unless File.basename($PROGRAM_NAME) == 'rake'
|
21
|
+
Rails.configuration.after_initialize do
|
22
|
+
# If you don't want listen a standard queue, comment this lines and
|
23
|
+
# "require 'actions'"
|
24
|
+
actions = RubyRabbitmqJanus::ActionEvents.new.actions
|
25
|
+
RubyRabbitmqJanus::Janus::Concurrencies::Event.instance.run(&actions)
|
26
|
+
end
|
26
27
|
end
|
27
|
-
end
|
28
28
|
INIT
|
29
29
|
|
30
30
|
# Create an initializer
|
@@ -6,30 +6,30 @@ module RubyRabbitmqJanus
|
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
7
|
desc 'Install RubyRabbitmqJanus in your Rails application'
|
8
8
|
ACTION_CLASS = <<-BASE
|
9
|
-
module RubyRabbitmqJanus
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
module RubyRabbitmqJanus
|
10
|
+
# Execute this code when janus return an events in standard queue
|
11
|
+
class ActionsEvents
|
12
|
+
# Default method using for sending a block of code
|
13
|
+
def actions
|
14
|
+
lambda do |reason, data|
|
15
|
+
Rails.logger.debug "Execute block code with reason : \#{reason}"
|
16
|
+
case reason
|
17
|
+
when event this case_events(data.to_hash)
|
18
|
+
end
|
18
19
|
end
|
19
20
|
end
|
20
|
-
end
|
21
21
|
|
22
|
-
|
22
|
+
private
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
def case_events(data)
|
25
|
+
Rails.logger.debug "Event : \#{data}"
|
26
|
+
end
|
26
27
|
end
|
27
28
|
end
|
28
|
-
end
|
29
29
|
BASE
|
30
30
|
APPLICATION = <<-AUTOLOAD
|
31
|
-
# Load RubyRabbitmqJanus actions events code blocks
|
32
|
-
config.autoload_paths += Dir[Rails.root.join('app', 'ruby_rabbitmq_janus')]
|
31
|
+
# Load RubyRabbitmqJanus actions events code blocks
|
32
|
+
config.autoload_paths += Dir[Rails.root.join('app', 'ruby_rabbitmq_janus')]
|
33
33
|
AUTOLOAD
|
34
34
|
|
35
35
|
# Generate initializer with default code
|
data/lib/rrj/errors/init.rb
CHANGED
data/lib/rrj/info.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# :reek:TooManyConstants
|
3
4
|
|
4
5
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
@@ -24,11 +25,11 @@ module RubyRabbitmqJanus
|
|
24
25
|
|
25
26
|
# Define a long description to gem
|
26
27
|
DESCRIPTION = <<-DESC
|
27
|
-
This gem is used to communicate to a server Janus through RabbitMQ software
|
28
|
-
(Message-oriented middleware). It waiting a messages to Rails API who send to
|
29
|
-
RabbitMQ server in a queue for janus server. Janus processes a message and
|
30
|
-
to RabbitMQ server in a queue for gem. Once the received message is
|
31
|
-
returned through the Rails API.
|
28
|
+
This gem is used to communicate to a server Janus through RabbitMQ software
|
29
|
+
(Message-oriented middleware). It waiting a messages to Rails API who send to
|
30
|
+
RabbitMQ server in a queue for janus server. Janus processes a message and
|
31
|
+
send to RabbitMQ server in a queue for gem. Once the received message is
|
32
|
+
decoded and returned through the Rails API.
|
32
33
|
DESC
|
33
34
|
|
34
35
|
# Define homepage
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'semaphore'
|
4
|
+
|
3
5
|
module RubyRabbitmqJanus
|
4
6
|
module Rabbit
|
5
7
|
# Define an module for create an publisher
|
@@ -15,26 +17,27 @@ module RubyRabbitmqJanus
|
|
15
17
|
#
|
16
18
|
# @abstract Publish message in RabbitMQ
|
17
19
|
class BasePublisher
|
18
|
-
attr_reader :
|
20
|
+
attr_reader :responses
|
19
21
|
|
20
22
|
# Define a base publisher
|
21
23
|
def initialize
|
22
24
|
Tools::Log.instance.debug 'Create an publisher'
|
23
|
-
@
|
24
|
-
@
|
25
|
+
@responses = []
|
26
|
+
@semaphore = Semaphore.new
|
25
27
|
@lock = Mutex.new
|
26
28
|
end
|
27
29
|
|
28
30
|
private
|
29
31
|
|
30
|
-
attr_accessor :
|
32
|
+
attr_accessor :semaphore, :lock
|
31
33
|
|
32
34
|
def return_response
|
35
|
+
@semaphore.wait
|
36
|
+
response = nil
|
33
37
|
@lock.synchronize do
|
34
|
-
|
35
|
-
@condition.wait(@lock)
|
36
|
-
@response
|
38
|
+
response = @responses.shift
|
37
39
|
end
|
40
|
+
response
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
@@ -14,18 +14,19 @@ module RubyRabbitmqJanus
|
|
14
14
|
# @param [String] rabbit Information connection to rabbitmq server
|
15
15
|
def initialize(rabbit)
|
16
16
|
super()
|
17
|
+
@responses = []
|
17
18
|
@rabbit = rabbit.channel
|
18
|
-
@response = nil
|
19
19
|
subscribe_queue
|
20
20
|
end
|
21
21
|
|
22
22
|
# Listen a queue and return a body response
|
23
23
|
def listen_events
|
24
|
+
semaphore.wait
|
25
|
+
response = nil
|
24
26
|
lock.synchronize do
|
25
|
-
|
26
|
-
Tools::Log.instance.info 'Janus event received .. treatment ..'
|
27
|
-
yield @response.event, @response
|
27
|
+
response = @responses.shift
|
28
28
|
end
|
29
|
+
yield response.event, response
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
@@ -48,10 +49,19 @@ module RubyRabbitmqJanus
|
|
48
49
|
{ block: false, manual_ack: true, arguments: { 'x-priority': 2 } }
|
49
50
|
end
|
50
51
|
|
52
|
+
# Counts transmitted messages
|
53
|
+
def log_message_id(propertie)
|
54
|
+
message_id = propertie.message_id
|
55
|
+
Tools::Log.instance.info "[X] Message reading with ID #{message_id}"
|
56
|
+
end
|
57
|
+
|
58
|
+
# Sending an signal when an response is reading in queue
|
51
59
|
def synchronize_response(info, payload)
|
52
|
-
|
60
|
+
lock.synchronize do
|
61
|
+
@responses.push(Janus::Responses::Event.new(JSON.parse(payload)))
|
62
|
+
end
|
53
63
|
@rabbit.acknowledge(info.delivery_tag, false)
|
54
|
-
|
64
|
+
semaphore.signal
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
@@ -37,13 +37,31 @@ module RubyRabbitmqJanus
|
|
37
37
|
|
38
38
|
def subscribe_to_queue
|
39
39
|
reply.subscribe do |_delivery_info, propertie, payload|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
propertie_correlation = p_correlation(propertie)
|
41
|
+
if m_correlation.eql?(propertie_correlation)
|
42
|
+
synchronize(payload)
|
43
|
+
else
|
44
|
+
Tools::Log.instance.error 'Response correlation ID mismatch (' \
|
45
|
+
"#{m_correlation}!=#{propertie_correlation})"
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
50
|
+
def m_correlation
|
51
|
+
@message.correlation
|
52
|
+
end
|
53
|
+
|
54
|
+
def p_correlation(propertie)
|
55
|
+
propertie.correlation_id
|
56
|
+
end
|
57
|
+
|
58
|
+
def synchronize(payload)
|
59
|
+
lock.synchronize do
|
60
|
+
responses.push(JSON.parse(payload))
|
61
|
+
end
|
62
|
+
semaphore.signal
|
63
|
+
end
|
64
|
+
|
47
65
|
attr_accessor :message
|
48
66
|
end
|
49
67
|
end
|
@@ -6,19 +6,19 @@ describe 'RubyRabbitmqJanus::RRJ -- message type offer', broken: true do
|
|
6
6
|
before(:example) do
|
7
7
|
@type = 'peer::offer'
|
8
8
|
@options = {
|
9
|
-
'sdp' =>
|
10
|
-
v=0
|
11
|
-
o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com
|
12
|
-
s=
|
13
|
-
c=IN IP4 host.atlanta.example.com
|
14
|
-
t=0 0
|
15
|
-
m=audio 49170 RTP/AVP 0 8 97
|
16
|
-
a=rtpmap:0 PCMU/8000
|
17
|
-
a=rtpmap:8 PCMA/8000
|
18
|
-
a=rtpmap:97 iLBC/8000
|
19
|
-
m=video 51372 RTP/AVP 31 32
|
20
|
-
a=rtpmap:31 H261/90000
|
21
|
-
a=rtpmap:32 MPV/90000
|
9
|
+
'sdp' => <<-SDP
|
10
|
+
v=0
|
11
|
+
o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com
|
12
|
+
s=
|
13
|
+
c=IN IP4 host.atlanta.example.com
|
14
|
+
t=0 0
|
15
|
+
m=audio 49170 RTP/AVP 0 8 97
|
16
|
+
a=rtpmap:0 PCMU/8000
|
17
|
+
a=rtpmap:8 PCMA/8000
|
18
|
+
a=rtpmap:97 iLBC/8000
|
19
|
+
m=video 51372 RTP/AVP 31 32
|
20
|
+
a=rtpmap:31 H261/90000
|
21
|
+
a=rtpmap:32 MPV/90000
|
22
22
|
SDP
|
23
23
|
}
|
24
24
|
end
|
@@ -4,8 +4,10 @@ shared_examples 'message is' do |type|
|
|
4
4
|
it { expect(message).to be_kind_of(type) }
|
5
5
|
end
|
6
6
|
|
7
|
+
# rubocop:disable Style/MixinGrouping
|
7
8
|
shared_examples 'message options keys is' do
|
8
9
|
it do
|
9
10
|
expect(message).to include(:routing_key, :correlation_id, :content_type)
|
10
11
|
end
|
11
12
|
end
|
13
|
+
# rubocop:enable Style/MixinGrouping
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_rabbitmq_janus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.pre.
|
4
|
+
version: 2.0.0.pre.106
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VAILLANT Jeremy
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.48.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.48.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,12 +248,26 @@ dependencies:
|
|
248
248
|
- - "~>"
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: 0.2.2
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: semaphore
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: 0.0.1
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: 0.0.1
|
265
|
+
description: |2
|
266
|
+
This gem is used to communicate to a server Janus through RabbitMQ software
|
267
|
+
(Message-oriented middleware). It waiting a messages to Rails API who send to
|
268
|
+
RabbitMQ server in a queue for janus server. Janus processes a message and
|
269
|
+
send to RabbitMQ server in a queue for gem. Once the received message is
|
270
|
+
decoded and returned through the Rails API.
|
257
271
|
email:
|
258
272
|
- jeremy@dazzl.tv
|
259
273
|
executables: []
|