ruby_rabbitmq_janus 2.6.0 → 2.7.0.pre.267

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea489f0b288e7ab0f6719d870f97d5959584107a7444cacb35140f36b7f8482b
4
- data.tar.gz: 3c38c6bb663244f4082e17f6ff279e1d3d52be685e9a631df33d172d411ea98e
3
+ metadata.gz: 11f0d4bb3cd5d101374bd3d9c00630434b7f707a09351661ba20f80af48d2f02
4
+ data.tar.gz: 96c04695329ac02a0912b94e9e72e190aab149e30ab6d0c4240d160b414b57dc
5
5
  SHA512:
6
- metadata.gz: 5bfffefc3c989fa939533bbd82c037299b38fe7cff649e88dd892440e1e28802dc540f9f35ae8676ba2be1cc39adfc0bfde6622da33efb0e51357327049a8f96
7
- data.tar.gz: e3572406ff23eace7233ab5ce1958614ff5b1f35f09079f77d8217ba42825de8f66d2bc080207d30ce4a52aa1b7acea1007d59e24fd393106a69f1dd223566ae
6
+ metadata.gz: 99d40057b30fc1e02d2f9bcf8f7bea00258225f1004efcbc3c80c33770ccaf127173e7e7f22bb4358a04b3a9d8d66ba406a580aea05944ec45f3f701f801884f
7
+ data.tar.gz: d69c11c8cfec3f4c3a34691856babf4768be3c96c11029a747067a8b9c54c9d33d7beb13a97a16ee57b7afa99d30b6f67e4f4cbb8fa003fde516b16f1e30e04b
data/config/default.md CHANGED
@@ -13,7 +13,6 @@ rabbit:
13
13
  pass: guest
14
14
  admin_pass: janusoverlord
15
15
  level: :info
16
- test: false
17
16
 
18
17
  queues:
19
18
  standard:
@@ -42,6 +41,7 @@ gem:
42
41
  environment: 'development'
43
42
  orm: 'mongoid'
44
43
  program_name: 'ruby_rabbitmq_janus'
44
+ response_path: 'spec/supports/rrj/responses'
45
45
  ```
46
46
 
47
47
  ## Customize
data/config/default.yml CHANGED
@@ -14,8 +14,6 @@ rabbit:
14
14
  admin_pass: janusoverlord
15
15
  # Logger level for rabbitmq message
16
16
  level: info
17
- # Test execution (with rspec ...)
18
- test: false
19
17
 
20
18
  # RabbitMQ Queue information
21
19
  queues:
@@ -79,3 +77,5 @@ gem:
79
77
  orm: 'mongoid'
80
78
  # Define program name
81
79
  program_name: 'ruby_rabbitmq_janus'
80
+ # Read response json for RSpec
81
+ response_path: 'spec/supports/rrj/responses'
@@ -1,30 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This test disable this gems execution when you running an task with rake
4
- # or if your start a Rails Console
5
- if File.basename($PROGRAM_NAME).match?('rake') || defined?(::Rails::Console)
6
- # Configure RRJ for rake task
7
- ::RRJ = RubyRabbitmqJanus::RRJTask.new
8
- else
9
- # Loading classes Actions to rails application
10
- require 'actions'
11
-
12
- # If you used gem config for manage your ENV variables uncomment this line
13
- # @see https://rubygems.org/gems/config
14
- # Settings.reload!
15
-
16
- # Initialize gem and create a number of session by Janus instance.
17
- ::RRJ = RubyRabbitmqJanus::RRJ.new
18
-
19
- # Use this initializer if your application use 'Admin/Monitor API'
20
- # @see https://janus.conf.meetecho.com/docs/admin.html
21
- # ::RRJ = RubyRabbitmqJanus::RRJAdmin.new
22
-
23
- # Send a block code to thread for manage event given by Janus in public queue
24
- Rails.configuration.after_initialize do
25
- # If you don't want listen a standard queue, comment this block and
26
- # "require 'actions'" also
27
- actions = RubyRabbitmqJanus::ActionEvents.new.actions
28
- RubyRabbitmqJanus::Janus::Concurrencies::Event.instance.run(&actions)
3
+ # Define methods for checking program is started.
4
+ # Is useless if your are a standalone program (just rails)
5
+ #
6
+ # Don't forgotten to add variable environment to your program.
7
+ #
8
+ # Methods for getting program name, test if rails/sidekiq/rrj ...
9
+ module Rails
10
+ # Check if application instance is a console rails
11
+ def self.console?
12
+ defined?(::Rails::Console)
29
13
  end
14
+
15
+ # Get variable name PROGRAM_NAME
16
+ # Don't use Config gem, it's loaded after this module
17
+ def self.pg_name
18
+ File.basename($PROGRAM_NAME) || ENV['PROGRAM_NAME']
19
+ end
20
+
21
+ # Check if application instance is Rails
22
+ def self.pg_rails?
23
+ PROGRAM.eql?('rails')
24
+ end
25
+
26
+ # Check if application instance is Sidekiq
27
+ def self.pg_sidekiq?
28
+ PROGRAM.eql?('sidekiq')
29
+ end
30
+
31
+ # Check if application instance is RubyRabbitmqJanus
32
+ def self.pg_rrj?
33
+ PROGRAM.eql?('ruby_rabbitmq_janus')
34
+ end
35
+
36
+ # Determine constant value for application instance
37
+ PROGRAM = console? ? 'console' : pg_name
30
38
  end
39
+
40
+
41
+ # If you used gem config for manage your ENV variables uncomment this line
42
+ # @see https://rubygems.org/gems/config
43
+ Settings.reload!
44
+
45
+ ::RRJ = case Rails::PROGRAM
46
+ when 'console', 'rake'
47
+ # Don't listen events in public queue to RabbitMQ.
48
+ # A thread exist with program application instance.
49
+ #
50
+ # Use this configuration if start rails console,
51
+ # rake or a sidekiq service.
52
+ RubyRabbitmqJanus::RRJTaskAdmin.new
53
+ when 'rspec'
54
+ # Use Bunny Mock gem. Is used with pipeline bitbucket.
55
+ RubyRabbitmqJanus::RRJRSpec.new
56
+ when 'sidekiq', 'rails', 'ruby_rabbitmq_janus'
57
+ # Reload env variable before start thread RRJ for
58
+ # listen events in RabbitMQ public queue.
59
+ # Load class manually.
60
+ # It's loaded after initializer so add manually here the listener block.
61
+ RubyRabbitmqJanus::RRJAdmin.new
62
+
63
+ # Comment/Remove this line if RRJ listener public queue is executed
64
+ # in another container/program
65
+ #
66
+ # Loading classes Actions to rails application
67
+ require 'actions'
68
+
69
+ # Send a block code to thread for manage event given by Janus in public queue
70
+ Rails.configuration.after_initialize do
71
+ # If you don't want listen a standard queue, comment this block and
72
+ # "require 'actions'" also
73
+ actions = RubyRabbitmqJanus::ActionEvents.new.actions
74
+ RubyRabbitmqJanus::Janus::Concurrencies::Event.instance.run(&actions)
75
+ end
76
+ end
data/lib/rrj/admin.rb CHANGED
@@ -25,11 +25,38 @@ module RubyRabbitmqJanus
25
25
  # end
26
26
  #
27
27
  # @since 2.0.0
28
+ # @deprecated Use {#admin_endpoint} instead.
28
29
  def start_transaction_admin(options = {})
29
30
  transaction = Janus::Transactions::Admin.new(options)
30
31
  transaction.connect { yield(transaction) }
31
32
  rescue
32
33
  raise Errors::RRJAdmin::StartTransactionAdmin, options
33
34
  end
35
+
36
+ # Create a transaction between Apps and Janus
37
+ #
38
+ # @param [Hash] options
39
+ # Give a session number for use another session in Janus
40
+ #
41
+ # @example List all sessions in Janus Instance
42
+ # instance = { 'instance' => 42 }
43
+ # @rrj.admin_endpoint(instance) do |transaction|
44
+ # response = transaction.publish_message('admin:sessions').sessions
45
+ # end
46
+ #
47
+ # @example Change log level to Janus Instance
48
+ # instance = { 'instance' => 42 }
49
+ # options = instance.merge({ 'level' => 5 })
50
+ # @rrj.admin_endpoint(options) do |transaction|
51
+ # response = transaction.publish_message('admin:set_log_level', options)
52
+ # end
53
+ #
54
+ # @since 2.7.0
55
+ def admin_endpoint(options = {})
56
+ transaction = Janus::Transactions::Admin.new(options)
57
+ transaction.connect { yield(transaction) }
58
+ rescue
59
+ raise Errors::RRJAdmin::StartTransactionAdmin, options
60
+ end
34
61
  end
35
62
  end
data/lib/rrj/info.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # Define constant to gem.
7
7
  module RubyRabbitmqJanus
8
8
  # Define version to gem
9
- VERSION = '2.6.0'
9
+ VERSION = '2.7.0'
10
10
 
11
11
  # Name to gem
12
12
  GEM_NAME = 'ruby_rabbitmq_janus'
data/lib/rrj/init.rb CHANGED
@@ -60,6 +60,8 @@ module RubyRabbitmqJanus
60
60
  # end
61
61
  #
62
62
  # @since 2.0.0
63
+ # @deprecated Use {#session_endpoint_public} or
64
+ # {#session_endpoint_private} instead.
63
65
  def start_transaction(exclusive = true, options = {})
64
66
  session = @option.use_current_session?(options)
65
67
  transaction = Janus::Transactions::Session.new(exclusive, session)
@@ -68,6 +70,60 @@ module RubyRabbitmqJanus
68
70
  raise Errors::RRJ::StartTransaction.new(exclusive, options)
69
71
  end
70
72
 
73
+ # Create a transaction between Apps and Janus in queue public
74
+ #
75
+ # @params [Hash] options
76
+ # @options [String] :instance (mandatory id cluster is enabled)
77
+ # @options [Integer] :session_id
78
+ # @options [Hash] :replace
79
+ # @options [Hash] :add
80
+ #
81
+ # @example Create a session
82
+ # instance : { 'instance' => 42 }
83
+ # @rrj.session_endpoint_public(instance) do |transaction|
84
+ # transaction.publish_message('base::create')
85
+ # end
86
+ #
87
+ # @example Destroy session in instance
88
+ # options = { 'instance' => 42, 'session_id' => 71984735765 }
89
+ # @rrj.session_endpoint_public(options) do |transaction|
90
+ # transaction.publish_message('base::destroy', options)
91
+ # end
92
+ #
93
+ # @since 2.7.0
94
+ def session_endpoint_public(options = {})
95
+ session = @option.use_current_session?(options)
96
+ transaction = Janus::Transactions::Session.new(false, session)
97
+ transaction.connect { yield(transaction) }
98
+ end
99
+
100
+ # Create a transaction between Apps and Janus in queue private
101
+ #
102
+ # @params [Hash] options
103
+ # @options [String] :instance (mandatory id cluster is enabled)
104
+ # @options [Integer] :session_id
105
+ # @options [Hash] :replace
106
+ # @options [Hash] :add
107
+ #
108
+ # @example Create a session
109
+ # instance : { 'instance' => 42 }
110
+ # @rrj.session_endpoint_public(instance) do |transaction|
111
+ # transaction.publish_message('base::create')
112
+ # end
113
+ #
114
+ # @example Destroy session in instance
115
+ # options = { 'instance' => 42, 'session_id' => 71984735765 }
116
+ # @rrj.session_endpoint_public(options) do |transaction|
117
+ # transaction.publish_message('base::destroy', options)
118
+ # end
119
+ #
120
+ # @since 2.7.0
121
+ def session_endpoint_private(options = {})
122
+ session = @option.use_current_session?(options)
123
+ transaction = Janus::Transactions::Session.new(true, session)
124
+ transaction.connect { yield(transaction) }
125
+ end
126
+
71
127
  # Start a transaction with Janus. Request used session_id/handle_id
72
128
  # information.
73
129
  #
@@ -92,6 +148,8 @@ module RubyRabbitmqJanus
92
148
  # @return [Fixnum] Handle used for transaction
93
149
  #
94
150
  # @since 2.0.0
151
+ # @deprecated Use {#handle_endpoint_public}
152
+ # or {#handle_endpoint_private} instead.
95
153
  def start_transaction_handle(exclusive = true, options = {})
96
154
  session = @option.use_current_session?(options)
97
155
  handle = @option.use_current_handle?(options)
@@ -105,6 +163,74 @@ module RubyRabbitmqJanus
105
163
  raise Errors::RRJ::StartTransactionHandle, exclusive, options
106
164
  end
107
165
 
166
+ # Create a transaction between Apps and Janus in private queue
167
+ #
168
+ # @param [Hash] options
169
+ # @options [String] :instance (mandatory id cluster is enabled)
170
+ # @options [Integer] :session_id (mandatory)
171
+ # @options [Integer] :handle_id
172
+ # @options [Hash] :replace
173
+ # @options [Hash] :add
174
+ #
175
+ # @example Post a offer
176
+ # options = {
177
+ # 'instance' => 42,
178
+ # 'session_id' => 71984735765,
179
+ # 'handle_id' => 56753748917,
180
+ # 'replace' => {
181
+ # 'sdp' => 'v=0\r\no=[..more sdp stuff..]'
182
+ # }
183
+ # }
184
+ # @rrj.handle_endpoint_public(options) do |transaction|
185
+ # transaction.publish_message('peer::offer', options)
186
+ # end
187
+ #
188
+ # @since 2.7.0
189
+ def handle_endpoint_public(options = {})
190
+ session = @option.use_current_session?(options)
191
+ handle = @option.use_current_handle?(options)
192
+ instance = options['instance'] || 1
193
+ transaction = Janus::Transactions::Handle.new(false,
194
+ session,
195
+ handle,
196
+ instance)
197
+ transaction.connect { yield(transaction) }
198
+ end
199
+
200
+ # Create a transaction between Apps and Janus
201
+ #
202
+ # @param [Hash] options
203
+ # @options [String] :instance (mandatory id cluster is enabled)
204
+ # @options [Integer] :session_id (mandatory)
205
+ # @options [Integer] :handle_id
206
+ # @options [Hash] :replace
207
+ # @options [Hash] :add
208
+ #
209
+ # @example Post a answer
210
+ # options = {
211
+ # 'instance' => 42,
212
+ # 'session_id' => 71984735765,
213
+ # 'handle_id' => 56753748917,
214
+ # 'replace' => {
215
+ # 'sdp' => 'v=0\r\no=[..more sdp stuff..]'
216
+ # }
217
+ # }
218
+ # @rrj.handle_endpoint_private(options) do |transaction|
219
+ # transaction.publish_message('peer::answer', options)
220
+ # end
221
+ #
222
+ # @since 2.7.0
223
+ def handle_endpoint_private(options = {})
224
+ session = @option.use_current_session?(options)
225
+ handle = @option.use_current_handle?(options)
226
+ instance = options['instance'] || 1
227
+ transaction = Janus::Transactions::Handle.new(true,
228
+ session,
229
+ handle,
230
+ instance)
231
+ transaction.connect { yield(transaction) }
232
+ end
233
+
108
234
  # Delete all resources to JanusInstance reference.
109
235
  # Warning: All data in database and Janus Instance is delete
110
236
  #
@@ -67,3 +67,4 @@ end
67
67
  require 'rrj/janus/responses/standard'
68
68
  require 'rrj/janus/responses/admin'
69
69
  require 'rrj/janus/responses/event'
70
+ require 'rrj/janus/responses/rspec'
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :reek:UtilityFunction
4
+
5
+ module RubyRabbitmqJanus
6
+ module Janus
7
+ module Responses
8
+ # Response for RSpec initializer
9
+ class RSpec
10
+ def initialize(type)
11
+ path = RubyRabbitmqJanus::Tools::Config.instance.rspec_response
12
+ @json = File.join(Dir.pwd,
13
+ path,
14
+ "#{type.gsub('::', '_')}.json")
15
+ end
16
+
17
+ def read
18
+ JSON.parse(File.read(@json))
19
+ end
20
+
21
+ def session
22
+ (rand * 1_000_000).to_i
23
+ end
24
+
25
+ def plugin
26
+ read['plugindata']
27
+ end
28
+
29
+ def plugin_data
30
+ read['plugindata']['data']
31
+ end
32
+
33
+ def data
34
+ read['data']
35
+ end
36
+
37
+ def sdp
38
+ read['jsep']
39
+ end
40
+
41
+ def sessions
42
+ read['sessions']
43
+ end
44
+
45
+ def info
46
+ read['info']
47
+ end
48
+
49
+ def keys
50
+ [546_321_963, 546_321_966]
51
+ end
52
+
53
+ def instance
54
+ JanusInstance.first
55
+ end
56
+
57
+ def enable
58
+ [True, False].sample
59
+ end
60
+
61
+ alias id session
62
+ alias session_id session
63
+ alias sender session
64
+ alias handles sessions
65
+ alias jsep sdp
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyRabbitmqJanus
4
+ module Janus
5
+ module Transactions
6
+ # Transaction for RSpec initializer
7
+ class RSpec
8
+ attr_reader :response
9
+
10
+ def initialize
11
+ @response = nil
12
+ end
13
+
14
+ def connect; end
15
+
16
+ def detach; end
17
+
18
+ def detach_for_deleting; end
19
+
20
+ def publish_message(type, _options)
21
+ @response = Janus::Responses::RSpec.new(type)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -57,3 +57,4 @@ end
57
57
  require 'rrj/janus/transactions/session'
58
58
  require 'rrj/janus/transactions/handle'
59
59
  require 'rrj/janus/transactions/admin'
60
+ require 'rrj/janus/transactions/rspec'
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rrj/rabbit/connect'
4
- require 'rrj/rabbit/connect_fake' \
5
- if RubyRabbitmqJanus::Tools::Config.instance.tester?
6
4
  require 'rrj/rabbit/base_event'
7
5
  require 'rrj/rabbit/propertie'
8
6
 
data/lib/rrj/rspec.rb CHANGED
@@ -1,8 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rrj/tools/gem/config'
4
+
5
+ # :reek:UtilityFunction
6
+
3
7
  module RubyRabbitmqJanus
4
8
  # # RRJRSpec
5
9
  #
6
10
  # Initializer to use with RSpec execution
7
- class RRJRSpec < RRJTaskAdmin; end
11
+ class RRJRSpec < RRJTaskAdmin
12
+ def initialize
13
+ RubyRabbitmqJanus::Tools::Config.instance
14
+ end
15
+
16
+ # @deprecated
17
+ def start_transaction(_exclusive, _options)
18
+ yield(RubyRabbitmqJanus::Janus::Transactions::RSpec.new)
19
+ end
20
+
21
+ # @deprecated
22
+ def start_transaction_handle(_exclusive, _options)
23
+ transaction = RubyRabbitmqJanus::Janus::Transactions::RSpec.new
24
+ yield(transaction)
25
+ transaction.response
26
+ end
27
+
28
+ # @deprecated
29
+ def start_transaction_admin(_options)
30
+ yield(RubyRabbitmqJanus::Janus::Transactions::RSpec.new)
31
+ end
32
+
33
+ alias session_endpoint_public start_transaction
34
+ alias session_endpoint_private start_transaction
35
+ alias handle_endpoint_public start_transaction_handle
36
+ alias handle_endpoint_private start_transaction_handle
37
+ alias admin_endpoint start_transaction_admin
38
+ end
8
39
  end
data/lib/rrj/task.rb CHANGED
@@ -29,6 +29,7 @@ module RubyRabbitmqJanus
29
29
  # end
30
30
  #
31
31
  # @since 2.1.0
32
+ # @deprecated Use {#session_endpoint_private} instead
32
33
  def start_transaction(options = {})
33
34
  transaction = Janus::Transactions::Session.new(true,
34
35
  options['session_id'])
@@ -37,6 +38,34 @@ module RubyRabbitmqJanus
37
38
  raise Errors::RRJ::StartTransaction.new(true, options)
38
39
  end
39
40
 
41
+ # Create a transaction between Apps and Janus in queue private
42
+ #
43
+ # @params [Hash] options
44
+ # @options [String] :instance (mandatory id cluster is enabled)
45
+ # @options [Integer] :session_id
46
+ # @options [Hash] :replace
47
+ # @options [Hash] :add
48
+ #
49
+ # @param [Hash] options
50
+ # Give a session number for use another session in Janus
51
+ #
52
+ # @example Get Janus information
53
+ # @rrj.session_endpoint_private do |transaction|
54
+ # response = transaction.publish_message('base::info').to_hash
55
+ # end
56
+ #
57
+ # @since 2.7.0
58
+ def session_endpoint_private(options = {})
59
+ transaction = Janus::Transactions::Session.new(true,
60
+ options['session_id'])
61
+ transaction.connect { yield(transaction) }
62
+ end
63
+
64
+ # For task is impossible to calling this method.
65
+ def session_endpoint_public(_options)
66
+ nil
67
+ end
68
+
40
69
  # Create a transaction between apps and janus with a handle
41
70
  #
42
71
  # @since 2.1.0
@@ -52,6 +81,45 @@ module RubyRabbitmqJanus
52
81
  raise Errors::RRJTask::StartTransactionHandle.new(exclusive, options)
53
82
  end
54
83
 
84
+ # For task is impossible to calling this method
85
+ def handle_endpoint_public(_options)
86
+ nil
87
+ end
88
+
89
+ # Create a transaction between Apps and Janus in queue private
90
+ #
91
+ # @params [Hash] options
92
+ # @options [String] :instance (mandatory id cluster is enabled)
93
+ # @options [Integer] :session_id
94
+ # @options [Hash] :replace
95
+ # @options [Hash] :add
96
+ #
97
+ # @example Post a offer
98
+ # options = {
99
+ # 'instance' => 42,
100
+ # 'session_id' => 71984735765,
101
+ # 'handle_id' => 56753748917,
102
+ # 'replace' => {
103
+ # 'sdp' => 'v=0\r\no=[..more sdp stuff..]'
104
+ # }
105
+ # }
106
+ # @rrj.handle_endpoint_private(options) do |transaction|
107
+ # transaction.publish_message('peer::offer', options)
108
+ # end
109
+ #
110
+ # @since 2.7.0
111
+ #
112
+ # :reek:FeatureEnvy
113
+ def handle_endpoint_private(options = {})
114
+ janus = session_instance(options)
115
+ handle = 0 # Create always a new handle
116
+ transaction = Janus::Transactions::Handle.new(true,
117
+ janus.session,
118
+ handle,
119
+ janus.instance)
120
+ transaction.connect { yield(transaction) }
121
+ end
122
+
55
123
  private
56
124
 
57
125
  def session_instance(options)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :reek:UtilityFunction
4
+
3
5
  module RubyRabbitmqJanus
4
6
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
5
7
 
@@ -7,12 +9,43 @@ module RubyRabbitmqJanus
7
9
  #
8
10
  # Used wit sidekiq/console/CI execution for admin queue in Janus gateway
9
11
  class RRJTaskAdmin < RRJTask
10
- # Crate a transaction between apps and Janus
12
+ # Create a transaction between apps and Janus
13
+ #
14
+ # @deprecated Use {#admin_endpoint} instead.
11
15
  def start_transaction_admin(options = {})
12
16
  transaction = Janus::Transactions::Admin.new(options)
13
17
  transaction.connect { yield(transaction) }
14
18
  rescue
15
19
  raise Errors::RRJAdmin::StartTransactionAdmin, options
16
20
  end
21
+
22
+ # Create a transaction between Apps and Janus
23
+ #
24
+ # This transaction is sending to admin/monitor API.
25
+ #
26
+ # @params [Hash] options
27
+ # @options [String] :instance (mandatory id cluster is enabled)
28
+ # @options [Integer] :session_id
29
+ # @options [Hash] :replace
30
+ # @options [Hash] :add
31
+ #
32
+ # @example List sessions
33
+ # options = { 'instance' => 42 }
34
+ # @rrj.handle_endpoint_private(options) do |transaction|
35
+ # transaction.publish_message('admin::list_sessions', options)
36
+ # end
37
+ #
38
+ #
39
+ # @example List handles
40
+ # options = { 'instance' => 42, 'session_id' => 71984735765 }
41
+ # @rrj.handle_endpoint_private(options) do |transaction|
42
+ # transaction.publish_message('admin::list_handles', options)
43
+ # end
44
+ #
45
+ # @since 2.7.0
46
+ def admin_endpoint(options = {})
47
+ transaction = Janus::Transactions::Admin.new(options)
48
+ transaction.connect { yield(transaction) }
49
+ end
17
50
  end
18
51
  end
@@ -50,6 +50,11 @@ module RubyRabbitmqJanus
50
50
  @options['gem']['program_name'].to_s || RubyRabbitmqJanus::GEM_NAME
51
51
  end
52
52
 
53
+ # @return [String] Get path for json files contains a Janus response
54
+ def rspec_response
55
+ @options['gem']['response_path'] || 'spec/responses'
56
+ end
57
+
53
58
  alias env environment
54
59
  alias orm object_relational_mapping
55
60
  alias pg program_name
@@ -20,11 +20,6 @@ module RubyRabbitmqJanus
20
20
  @options['rabbit']['level'].upcase.to_sym || :INFO
21
21
  end
22
22
 
23
- # @return [Boolean] read configuration for bunny execution
24
- def tester?
25
- @options['rabbit']['test'].to_s.match?('true') ? true : false
26
- end
27
-
28
23
  # @return [Hash] Format hash for bunny settings
29
24
  def server_settings
30
25
  Hash[%w[host port pass user vhost log_level].map do |value|
@@ -0,0 +1,32 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>",
4
+ "session_id" : 12345678,
5
+ "handle_id" : 98765432,
6
+ "info" : {
7
+ "session_id" : 12345678,
8
+ "session_last_activity": 7927759122,
9
+ "session_transport": "janus.transport.websockets",
10
+ "handle_id" : 98765432,
11
+ "opaque_id": "echotest-YZcsLRCI4uSV",
12
+ "loop-running": true,
13
+ "created": 18695669309,
14
+ "current_time": 18706199704,
15
+ "plugin": "janus.plugin.echotest",
16
+ "plugin_specific": {
17
+ },
18
+ "flags": {
19
+ },
20
+ "agent-created": 18696092523,
21
+ "ice-mode": "full",
22
+ "ice-role": "controlled",
23
+ "sdps": {
24
+ "profile": "UDP/TLS/RTP/SAVPF",
25
+ "local": "v=0[..]",
26
+ "remote": "v=0[..]"
27
+ },
28
+ "queued-packets": 0,
29
+ "streams": [
30
+ ]
31
+ }
32
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus" : "success",
3
+ "transaction" : "<same as the request>"
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "janus": "info",
3
+ "session_id": 3547439636123024,
4
+ "transaction": "JG3DBOZ046"
5
+ }
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: 2.6.0
4
+ version: 2.7.0.pre.267
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-29 00:00:00.000000000 Z
11
+ date: 2019-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -332,20 +332,6 @@ dependencies:
332
332
  - - "~>"
333
333
  - !ruby/object:Gem::Version
334
334
  version: '2.5'
335
- - !ruby/object:Gem::Dependency
336
- name: bunny-mock
337
- requirement: !ruby/object:Gem::Requirement
338
- requirements:
339
- - - "~>"
340
- - !ruby/object:Gem::Version
341
- version: '1.7'
342
- type: :runtime
343
- prerelease: false
344
- version_requirements: !ruby/object:Gem::Requirement
345
- requirements:
346
- - - "~>"
347
- - !ruby/object:Gem::Version
348
- version: '1.7'
349
335
  - !ruby/object:Gem::Dependency
350
336
  name: key_path
351
337
  requirement: !ruby/object:Gem::Requirement
@@ -525,9 +511,11 @@ files:
525
511
  - lib/rrj/janus/responses/event.rb
526
512
  - lib/rrj/janus/responses/janus_instance.rb
527
513
  - lib/rrj/janus/responses/response.rb
514
+ - lib/rrj/janus/responses/rspec.rb
528
515
  - lib/rrj/janus/responses/standard.rb
529
516
  - lib/rrj/janus/transactions/admin.rb
530
517
  - lib/rrj/janus/transactions/handle.rb
518
+ - lib/rrj/janus/transactions/rspec.rb
531
519
  - lib/rrj/janus/transactions/session.rb
532
520
  - lib/rrj/janus/transactions/transaction.rb
533
521
  - lib/rrj/models/active_record.rb
@@ -537,7 +525,6 @@ files:
537
525
  - lib/rrj/models/mongoid.rb
538
526
  - lib/rrj/rabbit/base_event.rb
539
527
  - lib/rrj/rabbit/connect.rb
540
- - lib/rrj/rabbit/connect_fake.rb
541
528
  - lib/rrj/rabbit/listener/base.rb
542
529
  - lib/rrj/rabbit/listener/from.rb
543
530
  - lib/rrj/rabbit/listener/from_admin.rb
@@ -612,6 +599,14 @@ files:
612
599
  - spec/request/peer/request_offer_spec.rb
613
600
  - spec/request/peer/request_trickle_spec.rb
614
601
  - spec/request/peer/request_trickles_spec.rb
602
+ - spec/responses/admin_handle_info.json
603
+ - spec/responses/admin_list_handles.json
604
+ - spec/responses/admin_list_sessions.json
605
+ - spec/responses/admin_set_libnice_debug.json
606
+ - spec/responses/admin_set_locking_debug.json
607
+ - spec/responses/admin_set_log_colors.json
608
+ - spec/responses/admin_set_log_level.json
609
+ - spec/responses/base_info.json
615
610
  - spec/rrj/ruby_rabbitmq_janus_spec.rb
616
611
  - spec/ruby_rabbitmq_janus/janus/concurrencies/concurrency_spec.rb
617
612
  - spec/ruby_rabbitmq_janus/janus/concurrencies/keepalive_initializer_spec.rb
@@ -704,9 +699,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
704
699
  version: '0'
705
700
  required_rubygems_version: !ruby/object:Gem::Requirement
706
701
  requirements:
707
- - - ">="
702
+ - - ">"
708
703
  - !ruby/object:Gem::Version
709
- version: '0'
704
+ version: 1.3.1
710
705
  requirements: []
711
706
  rubygems_version: 3.0.6
712
707
  signing_key:
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bunny-mock'
4
-
5
- # :reek:FeatureEnvy
6
-
7
- module RubyRabbitmqJanus
8
- module Rabbit
9
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
10
- #
11
- # Override class connect with a Faker connection with rabbitmq
12
- class ConnectFake
13
- # Initialize connection to server RabbitMQ
14
- def initialize
15
- @rabbit = BunnyMock.new.start
16
- rescue => exception
17
- raise Errors::Rabbit::Connect::Initialize, exception
18
- end
19
-
20
- # Create an transaction with rabbitmq and close after response is received
21
- def transaction_short
22
- response = fake_transaction
23
- close
24
- response
25
- rescue => exception
26
- raise Errors::Rabbit::Connect::TransactionShort, exception
27
- end
28
-
29
- # Create an transaction with rabbitmq and not close
30
- def transaction_long
31
- start
32
- @rabbit.channel.queue.pop[:message]
33
- rescue => exception
34
- raise Errors::Rabbit::Connect::TransactionLong, exception
35
- end
36
-
37
- # Opening a connection with RabbitMQ
38
- def start
39
- @rabbit.start
40
- rescue => exception
41
- raise Errors::Rabbit::Connect::Start, exception
42
- end
43
-
44
- # Close connection to server RabbitMQ
45
- def close
46
- @rabbit.close
47
- rescue => exception
48
- raise Errors::Rabbit::Connect::Close, exception
49
- end
50
-
51
- # Create an channel
52
- def channel
53
- @rabbit.channel
54
- rescue => exception
55
- raise Errors::Rabbit::Connect::Channel, exception
56
- end
57
-
58
- private
59
-
60
- def fake_transaction
61
- channel = @rabbit.channel
62
- queue = channel.queue 'janus-queue-test'
63
- queue.publish 'RSpec testing message'
64
- queue.pop
65
- end
66
- end
67
- end
68
- end