ruby_rabbitmq_janus 1.1.12 → 1.2.0

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +127 -0
  3. data/Rakefile +1 -3
  4. data/config/default.md +14 -14
  5. data/config/default.yml +12 -18
  6. data/config/requests.md +80 -0
  7. data/config/requests/{channel → peer}/answer.json +1 -1
  8. data/config/requests/{channel → peer}/offer.json +0 -0
  9. data/lib/generators/ruby_rabbitmq_janus/install_generator.rb +1 -0
  10. data/lib/rrj/errors/config.rb +8 -1
  11. data/lib/rrj/errors/error.rb +18 -5
  12. data/lib/rrj/errors/janus.rb +4 -2
  13. data/lib/rrj/errors/janus_message.rb +19 -15
  14. data/lib/rrj/errors/janus_response.rb +13 -26
  15. data/lib/rrj/errors/janus_transaction.rb +7 -13
  16. data/lib/rrj/errors/rabbit.rb +3 -9
  17. data/lib/rrj/info.rb +1 -1
  18. data/lib/rrj/init.rb +118 -68
  19. data/lib/rrj/janus/processus/concurrency.rb +8 -22
  20. data/lib/rrj/janus/processus/event.rb +13 -15
  21. data/lib/rrj/janus/processus/keepalive.rb +20 -15
  22. data/lib/rrj/janus/responses/response.rb +0 -1
  23. data/lib/rrj/janus/transactions/admin.rb +14 -22
  24. data/lib/rrj/janus/transactions/handle.rb +19 -33
  25. data/lib/rrj/janus/transactions/session.rb +13 -6
  26. data/lib/rrj/janus/transactions/transaction.rb +16 -24
  27. data/lib/rrj/rabbit/connect.rb +3 -4
  28. data/lib/rrj/rabbit/propertie.rb +6 -9
  29. data/lib/rrj/rabbit/publish/admin.rb +1 -1
  30. data/lib/rrj/rabbit/publish/base_publisher.rb +5 -0
  31. data/lib/rrj/rabbit/publish/listener.rb +1 -1
  32. data/lib/rrj/rabbit/publish/non_exclusive.rb +1 -1
  33. data/lib/rrj/tools/config.rb +44 -18
  34. data/lib/rrj/tools/log.rb +30 -15
  35. data/lib/rrj/tools/replaces/admin.rb +1 -3
  36. data/lib/rrj/tools/replaces/replace.rb +1 -6
  37. data/lib/rrj/tools/requests.rb +8 -8
  38. data/lib/rrj/tools/tools.rb +0 -1
  39. data/lib/ruby_rabbitmq_janus.rb +1 -0
  40. data/spec/request/admin/request_handle_info_spec.rb +3 -3
  41. data/spec/request/base/request_attach_spec.rb +7 -10
  42. data/spec/request/base/request_detach_spec.rb +6 -9
  43. data/spec/request/peer/request_answer_spec.rb +66 -0
  44. data/spec/request/peer/request_offer_spec.rb +113 -0
  45. data/spec/request/peer/request_trickle_spec.rb +9 -11
  46. data/spec/rrj/rrj_log_spec.rb +1 -6
  47. data/spec/spec_helper.rb +0 -1
  48. data/spec/support/examples.rb +6 -9
  49. data/spec/support/schemas/config/config.json +20 -32
  50. data/spec/support/schemas/request/peer/answer.json +15 -0
  51. data/spec/support/schemas/request/peer/offer.json +15 -0
  52. data/spec/support/schemas/request/peer/trickle.json +4 -12
  53. metadata +10 -19
  54. data/config/requests/channel/README.md +0 -29
  55. data/config/requests/channel/create.json +0 -9
  56. data/config/requests/channel/describe.json +0 -10
  57. data/config/requests/channel/destroy.json +0 -10
  58. data/config/requests/channel/exists.json +0 -10
  59. data/config/requests/channel/join.json +0 -11
  60. data/config/requests/channel/leave.json +0 -11
  61. data/config/requests/channel/list.json +0 -9
  62. data/config/requests/channel/select.json +0 -11
  63. data/config/requests/channel/trickle.json +0 -10
  64. data/config/requests/videocast/join.json +0 -12
  65. data/config/requests/videocast/leave.json +0 -11
  66. data/config/ruby-rabbitmq-janus.yml +0 -27
  67. data/lib/rrj/errors/request.rb +0 -21
  68. data/lib/rrj/tools/env.rb +0 -22
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
- # :reek:FeatureEnvy
3
2
 
4
3
  module RubyRabbitmqJanus
5
4
  module Errors
6
5
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
+
7
7
  # Define errors to message sending and response to janus
8
8
  class JanusError < RRJError
9
+ # Initialize a error standard for janus module
10
+ # @param [String] message Text returning in raise
9
11
  def initialize(message)
10
- super "[JANUS] #{message}", :fatal
12
+ super "[JANUS]#{message}", :fatal
11
13
  end
12
14
  end
13
15
  end
@@ -3,42 +3,46 @@
3
3
  module RubyRabbitmqJanus
4
4
  module Errors
5
5
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
+
6
7
  # Define an exception for janus message class
7
8
  class JanusMessage < JanusError
9
+ # Initialize a error for janus message module
10
+ # @param [String] message Text returning in raise
8
11
  def initialize(message)
9
- super "[Message] Error create : #{message}"
12
+ super "[Message] #{message}"
10
13
  end
11
14
  end
12
15
 
13
16
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
17
+
14
18
  # Define an exception for janus message to_json
15
- class JanusMessageJson < JanusError
19
+ class JanusMessageJson < JanusMessage
20
+ # Initialize a error for janus message in to_json
21
+ # @param [String] message Text returning in raise
16
22
  def initialize(message)
17
- super "[Message] Error transform to json : #{message}"
23
+ super "Error transform to json : #{message}"
18
24
  end
19
25
  end
20
26
 
21
27
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
28
+
22
29
  # Define an exception for janus message to_nice_json
23
- class JanusMessagePrettyJson < JanusError
30
+ class JanusMessagePrettyJson < JanusMessage
31
+ # Initialize a error for janus message in to_nice_json
32
+ # @param [String] message Text returning in raise
24
33
  def initialize(message)
25
- super "[Message] Error transform to pretty json : #{message}"
34
+ super "Error transform to pretty json : #{message}"
26
35
  end
27
36
  end
28
37
 
29
38
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
30
- # Define an exception for janus message to_hash
31
- class JanusMessageHash < JanusError
32
- def initialize(message)
33
- super "[Message] Error transform to hash : #{message}"
34
- end
35
- end
36
39
 
37
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
38
- # Define an exception for janus message option
39
- class JanusMessageOption < JanusError
40
+ # Define an exception for janus message to_hash
41
+ class JanusMessageHash < JanusMessage
42
+ # Initialize a error for janus message in to_hash
43
+ # @param [String] message Text returning in raise
40
44
  def initialize(message)
41
- super "[Message] Error options to message : #{message}"
45
+ super "Error transform to hash : #{message}"
42
46
  end
43
47
  end
44
48
  end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
- # :reek:FeatureEnvy
3
2
 
4
3
  module RubyRabbitmqJanus
5
4
  module Errors
6
5
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
+ #
7
7
  # Define an error primary for response
8
8
  class JanusResponse < JanusError
9
+ # Initialize a error for janus response module
10
+ # @param [String] message Text returning in raise
9
11
  def initialize(message)
10
12
  super "[Response] #{message}"
11
13
  end
@@ -14,31 +16,18 @@ module RubyRabbitmqJanus
14
16
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
15
17
  # Define an error for response initalize
16
18
  class JanusResponseInit < JanusResponse
19
+ # Initialize a error for janus response module in initializer
20
+ # @param [String] message Text returning in raise
17
21
  def initialize(message)
18
22
  super "Error create object : #{message}"
19
23
  end
20
24
  end
21
25
 
22
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
23
- # Define an error for simple message
24
- class JanusResponseSimple < JanusResponse
25
- def initialize(message)
26
- error = message['error']
27
- super "[#{error['code']}] #{error['reason']} -- #{message}"
28
- end
29
- end
30
-
31
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
32
- # Define an error for plugin
33
- class JanusResponsePlugin < JanusResponse
34
- def initialize(message)
35
- super "[#{message['error_code']}] #{message['error']}"
36
- end
37
- end
38
-
39
26
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
40
27
  # Define an exception for json
41
28
  class JanusResponseJson < JanusResponse
29
+ # Initialize a error for janus response module in to_json
30
+ # @param [String] message Text returning in raise
42
31
  def initialize(message)
43
32
  super \
44
33
  "Error transform to JSON : #{message[0]} -- message : #{message[1]}"
@@ -48,6 +37,8 @@ module RubyRabbitmqJanus
48
37
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
49
38
  # Define an exception for nice_json
50
39
  class JanusResponsePrettyJson < JanusResponse
40
+ # Initialize a error for janus response module in to_nice_json
41
+ # @param [String] message Text returning in raise
51
42
  def initialize(message)
52
43
  super "Error transform to Pretty JSON : #{message}"
53
44
  end
@@ -56,23 +47,19 @@ module RubyRabbitmqJanus
56
47
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
57
48
  # Define an exception for hash
58
49
  class JanusResponseHash < JanusResponse
50
+ # Initialize a error for janus response module in to_hash
51
+ # @param [String] message Text returning in raise
59
52
  def initialize(message)
60
53
  super \
61
54
  "Error transform to Hash : #{message[0]} -- message : #{message[1]}"
62
55
  end
63
56
  end
64
57
 
65
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
66
- # Define an error for response plugin
67
- class JanusResponsePluginData < JanusResponse
68
- def initialize(message)
69
- super "Error data response : #{message}"
70
- end
71
- end
72
-
73
58
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
74
59
  # Define an error for response data
75
60
  class JanusResponseDataId < JanusResponse
61
+ # Initialize a error for janus response module in data_id
62
+ # @param [String] message Text returning in raise
76
63
  def initialize(message)
77
64
  super "Error Data : #{message}"
78
65
  end
@@ -3,10 +3,10 @@
3
3
  module RubyRabbitmqJanus
4
4
  module Errors
5
5
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
- # Define errors to message sending and response to janus
7
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
8
- # Define an exception for initaliser transaction
6
+ # Define an exception for initalizer transaction
9
7
  class JanusTransaction < JanusError
8
+ # Initialize a error for janus transaction class
9
+ # @param [String] message Text returning in raise
10
10
  def initialize(message)
11
11
  super "[Transaction] Error initialize : #{message}"
12
12
  end
@@ -14,17 +14,11 @@ module RubyRabbitmqJanus
14
14
 
15
15
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
16
16
  # Define an exception for running_handle
17
- class JanusTransactionHandle
18
- def initialize(message)
19
- super "[Transaction] Error handle #{message}"
20
- end
21
- end
22
-
23
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
24
- # Define an exception for sending_message
25
- class JanusTransactionPost < JanusError
17
+ class JanusTransactionHandle < JanusTransaction
18
+ # Initialize a error for janus transaction handle class
19
+ # @param [String] message Text returning in raise
26
20
  def initialize(message)
27
- super "[Transaction] Error sending message : #{message}"
21
+ super "[Handle] #{message}"
28
22
  end
29
23
  end
30
24
  end
@@ -2,17 +2,11 @@
2
2
 
3
3
  module RubyRabbitmqJanus
4
4
  module Errors
5
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
- # Define errors with Rabbitmq when request is not sending
7
- class RequestNotExecuted < Errors::RRJError
8
- def initialize(request)
9
- super "Error in request executed : #{request}", :error
10
- end
11
- end
12
-
13
5
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
14
6
  # Define errors if connection to rabbitmq is failed
15
- class ConnectionRabbitmqFailed < Errors::RRJError
7
+ class ConnectionRabbitmqFailed < RRJError
8
+ # Initialize a error for rabbit module. It's a fatal error
9
+ # @param [String] message Text returning in raise
16
10
  def initialize(message)
17
11
  super message, :fatal
18
12
  end
data/lib/rrj/info.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Define constant to gem.
4
4
  module RubyRabbitmqJanus
5
5
  # Define version to gem
6
- VERSION = '1.1.12'
6
+ VERSION = '1.2.0'
7
7
 
8
8
  # Define a summary description to gem
9
9
  SUMMARY = 'Ruby RabbitMQ Janus'
data/lib/rrj/init.rb CHANGED
@@ -8,24 +8,37 @@ require 'bunny'
8
8
  require 'logger'
9
9
  require 'key_path'
10
10
  require 'active_support'
11
+ require 'erb'
11
12
 
13
+ # Primary module for this gem
12
14
  module RubyRabbitmqJanus
13
15
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
16
+
17
+ # # RubyRabbitmqJanus - RRJ
18
+ #
14
19
  # Initialize RRJ gem and create automatically a session with janus and
15
20
  # sending a keepalive message. The Time To Live is configured in yaml
16
- # configuration file 'config/default.yml' or
17
- # 'config/ruby-rabbitmq-janus.yml'.
21
+ # configuration file `config/default.yml` or if you a customize config in
22
+ # `config/ruby-rabbitmq-janus.yml`.
23
+ #
18
24
  # @!attribute [r] session
19
- # @return [Fixnum] Return an session number created in instantiate this gem.
20
- # :reek:BooleanParameter and :reek:ControlParameter and :reek:DataClump
21
- # :reek:LongParameterList and :reek:TooManyStatements
25
+ # @return [Fixnum] Return an session number created when this gem is
26
+ # instanciate. It's janus who creates the number of the session.
27
+ #
28
+ # @see file:/config/requests.md For more information to type requests used.
29
+ # @see file:/config/default.md For more information to config file used.
22
30
  class RRJ
23
31
  attr_reader :session
24
32
 
25
- # Returns a new instance of RubyRabbitmqJanus
33
+ # Return a new instance of RubyRabbitmqJanus.
34
+ #
35
+ # @example Create a instance to this gem
36
+ # @rrj = RubyRabbitmqJanus::RRJ.new
37
+ # => #<RubyRabbitmqJanus::RRJ:0x007 @session=123, @transaction=nil>
26
38
  def initialize
27
- # Instanciate singleton tools
28
- start_instances_tools
39
+ Tools::Log.instance
40
+ Tools::Config.instance
41
+ Tools::Requests.instance
29
42
 
30
43
  # Create an session while time opening
31
44
  @session = Janus::Concurrencies::Keepalive.instance.session
@@ -34,118 +47,157 @@ module RubyRabbitmqJanus
34
47
  @transaction = nil
35
48
  end
36
49
 
37
- # Send an simple message to janus. No options in request with this method.
50
+ # Send an simple message to janus.
51
+ #
38
52
  # @param [String] type
39
53
  # Given a type to request. JSON request writing in 'config/requests/'
40
54
  # @param [Bollean] exclusive
41
55
  # Use an exclusive queue or not
56
+ # @param [Hash] options Options update in request
57
+ #
42
58
  # @example Sending an message info in queue 'to-janus'
43
59
  # RubyRabbitmqJanus::RRJ.new.message_simple('base::info', true)
44
60
  # #=> {}
45
61
  # @example Sending an message info in queue exclusive 'ampq.gen-xxxxx'
46
62
  # RubyRabbitmqJanus::RRJ.new.message_simple('base::info')
47
63
  # #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
64
+ #
48
65
  # @return [RubyRabbitmqJanus::Janus::Responses::Standard]
49
66
  # Give an object response to janus server
50
- def message_simple(type = 'base::info', exclusive = false, options = {})
51
- Janus::Transactions::Transaction.new(@session).connect(exclusive) do
67
+ #
68
+ # @since 1.0.0
69
+ def message_simple(type = 'base::info', exclusive = false,
70
+ options = { 'replace' => {}, 'add' => {} })
71
+ Janus::Transactions::Session.new(@session).connect(exclusive) do
52
72
  Janus::Messages::Standard.new(type, options)
53
73
  end
54
74
  end
55
75
 
56
76
  # Send an message simple in current session.
77
+ #
57
78
  # @param [String] type
58
79
  # Given a type to request. JSON request writing in 'config/requests/'
59
80
  # @param [Hash] options Options update in request
60
81
  # @param [Bollean] exclusive
61
82
  # Use an exclusive queue or not
83
+ #
62
84
  # @example Sending an message create
63
85
  # RubyRabbitmqJanus::RRJ.new.message_session('base::create')
64
- # #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
86
+ # n#=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
87
+ #
65
88
  # @return [RubyRabbitmqJanus::Janus::Responses::Standard]
66
- # Give an object response to janus server
67
- def message_session(type, options = {}, exclusive = true)
68
- Janus::Transactions::Session.new(@session).session_connect(exclusive) do
89
+ # Give an object response to janus server
90
+ #
91
+ # @since 1.0.0
92
+ def message_session(type, options = { 'replace' => {}, 'add' => {} },
93
+ exclusive = true)
94
+ Janus::Transactions::Session.new(@session).connect(exclusive) do
69
95
  Janus::Messages::Standard.new(type, use_current_session?(options))
70
96
  end
71
97
  rescue => error
72
98
  raise Errors::RRJErrorPost, error
73
99
  end
74
100
 
75
- # Send a message simple for admin Janus
101
+ # Send a message simple for admin Janus.
102
+ # **Is used just for sending a message to Janus Monitor/Admin API**. The
103
+ # queue is exclusive for not transmitting data to anyone.
104
+ #
76
105
  # @param [String] type
77
- # Given a type to request. JSON request writing in 'config/requests/'
78
- # @param [Hash] options Options update in request
106
+ # Given a type to request. JSON request writing in `config/requests/`
107
+ # @param [Hash] options Fields updating in request sending to janus.
108
+ # **This hash must imperatively contains the key `replace`**
109
+ # @option options [Hash] :replace Contains all fields who be replaced in
110
+ # request sending to janus.
111
+ # @option options [Hash] :add Contains all fields adding to request.
112
+ #
79
113
  # @example Sending an message create
80
114
  # RubyRabbitmqJanus::RRJ.new.message_admin('admin::sessions')
81
115
  # #=> {"janus":"success","sessions": [12345, 8786567465465, ...] }
116
+ #
82
117
  # @return [RubyRabbitmqJanus::Janus::Responses::Standard]
83
- # Give an object response to janus server
84
- def message_admin(type, options = {})
85
- Janus::Transactions::Admin.new(use_current_session?(options)).connect do
86
- Janus::Messages::Admin.new(type, options)
87
- end
118
+ # Give an object response to janus server
119
+ #
120
+ # @since 1.0.0
121
+ def message_admin(type, options = { 'replace' => {}, 'add' => {} })
122
+ @transaction = Janus::Transactions::Admin.new(@session,
123
+ true,
124
+ handle?(options))
125
+ @transaction.connect { Janus::Messages::Admin.new(type, options) }
88
126
  end
89
127
 
90
128
  # Send an message in handle session in current session.
129
+ #
91
130
  # @param [String] type
92
131
  # Given a type to request. JSON request writing in 'config/requests/'
93
- # @param [Hash] replace Options update in request
94
- # @param [Hash] add Elements adding to request
132
+ # @param [Hash] options Fields updating in request sending to janus.
133
+ # **This hash must imperatively contains the key `replace`**
134
+ # @option options [Hash] :replace Contains all fields who be replaced in
135
+ # request sending to janus.
136
+ # @option options [Hash] :add Contains all fields adding to request.
137
+ #
95
138
  # @example Sending an message create
96
139
  # RubyRabbitmqJanus::RRJ.new.message_session('base::create')
97
140
  # #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
141
+ #
98
142
  # @return [RubyRabbitmqJanus::Janus::Responses::Standard]
99
- # Give an object response to janus server
100
- def message_handle(type, replace = {}, add = {})
101
- options = { 'replace' => replace, 'add' => add }
143
+ # Give a object response to janus server
144
+ #
145
+ # @since 1.0.0
146
+ def message_handle(type, options = { 'replace' => {}, 'add' => {} })
102
147
  @transaction.publish_message_handle(type, options)
103
148
  end
104
149
 
105
150
  # Define an handle transaction and establish connection with janus
151
+ #
152
+ # @param [Bollean] exclusive
153
+ # Use an exclusive queue or not
154
+ #
155
+ # @yield Sending requests to Janus.
156
+ #
157
+ # @example Start a transaction with janus with a exclusive queue
158
+ # @rrj.start_handle(true) do
159
+ # @rrj.message_handle('peer:trickle')
160
+ # end
161
+ #
162
+ # @see #message_handle
163
+ #
164
+ # @since 1.0.0
106
165
  def start_handle(exclusive = false)
107
- @transaction = Janus::Transactions::Handle.new(@session)
108
- @transaction.handle_connect(exclusive) { yield }
166
+ @transaction = Janus::Transactions::Handle.new(@session, exclusive)
167
+ @transaction.connect { yield }
109
168
  rescue => error
110
169
  raise Errors::RRJErrorHandle, error
111
170
  end
112
171
 
113
- # Define an handle admin transaction and establish connection with janus
114
- def start_handle_admin
115
- @transaction = Janus::Transactions::Admin.new(@session)
116
- @transaction.handle_connect { yield }
117
- rescue => error
118
- raise Errors::RRJErrorHandle, error
119
- end
120
-
121
- # Stop an handle existing in session running
122
- def stop_handle
123
- @transaction.handle_running_stop
124
- end
125
-
126
- # Start an short transaction. Create an handle and send a message to queue.
127
- # This queue is not exclusive, so this message is sending in queue
128
- # 'to-janus' and a response is return in queue 'from-janus'
172
+ # Start an short transaction. Create an handle and send one message to
173
+ # queue. **This queue is not exclusive**, so this message is sending in
174
+ # queue 'to-janus' and a response is return in queue 'from-janus'.
175
+ #
176
+ # @param [String] type
177
+ # Given a type to request. JSON request writing in 'config/requests/'
178
+ # @param [Hash] options Fields updating in request sending to janus.
179
+ # **This hash must imperatively contains the key `replace`**
180
+ # @option options [Hash] :replace Contains all fields who be replaced in
181
+ # request sending to janus.
182
+ # @option options [Hash] :add Contains all fields adding to request.
183
+ #
129
184
  # @example Send an request trickle
130
- # candidate = {
185
+ # cdn = {
131
186
  # 'candidate' => {
132
187
  # 'sdpMid' => 'video',
133
188
  # 'sdpMLineIndex' => 1,
134
189
  # 'candidate' => '...'
135
190
  # }
136
191
  # }
137
- # RubyRabbitmqJanus::RRJ.new.handle_message_simple('peer::trickle',
138
- # candidate)
139
- # #=> { 'janus' => 'trickle', ..., 'candidate' => {
140
- # 'completed' : true
141
- # }
142
- # }
143
- def handle_message_simple(type, replace = {}, add = {}, exclusive = false)
144
- handle = replace.include?('handle_id') ? replace['handle_id'] : 0
145
- @transaction = Janus::Transactions::Handle.new(@session)
146
- @transaction.handle_connect_and_stop(exclusive, handle) do
147
- message_handle(type, replace, add)
148
- end
192
+ # RubyRabbitmqJanus::RRJ.new.handle_message_simple('peer::trickle', cdn)
193
+ # #=> { 'janus' => 'trickle', ..., 'candidate' => { ... } }
194
+ #
195
+ # @since 1.0.0
196
+ def handle_message_simple(type, options = { 'replace' => {}, 'add' => {} })
197
+ @transaction = Janus::Transactions::Handle.new(@session,
198
+ false,
199
+ handle?(options))
200
+ @transaction.connect { message_handle(type, options) }
149
201
  rescue => error
150
202
  raise Errors::RRJErrorHandle, error
151
203
  end
@@ -154,17 +206,15 @@ module RubyRabbitmqJanus
154
206
 
155
207
  attr_accessor :transaction
156
208
 
157
- # Start singleton instances
158
- def start_instances_tools
159
- Tools::Env.instance
160
- Tools::Log.instance
161
- Tools::Config.instance
162
- Tools::Requests.instance
163
- end
164
-
165
- # Return a current session if not specified
166
209
  def use_current_session?(option)
167
210
  { 'session_id' => @session } unless option.key?('session_id')
168
211
  end
212
+
213
+ def handle?(options)
214
+ # if options.key?('replace') && options['replace'].key?('handle_id')
215
+ # options['replace'].key?('handle_id') ? replace['handle_id'] : 0
216
+ # end
217
+ options['replace'].key?('handle_id') ? replace['handle_id'] : 0
218
+ end
169
219
  end
170
220
  end