ruby_rabbitmq_janus 1.2.9 → 2.0.0.pre.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +145 -32
- data/config/default.yml +2 -0
- data/config/requests.md +2 -1
- data/config/requests/admin/add_token.json +6 -0
- data/config/requests/admin/allow_token.json +6 -0
- data/config/requests/admin/disallow_token.json +6 -0
- data/config/requests/admin/handle_info.json +1 -1
- data/config/requests/admin/handles.json +1 -1
- data/config/requests/admin/remove_token.json +6 -0
- data/config/requests/admin/sessions.json +1 -1
- data/config/requests/admin/set_locking_debug.json +6 -0
- data/config/requests/admin/{log_level.json → set_log_level.json} +1 -1
- data/config/requests/admin/tokens.json +5 -0
- data/config/requests/base/attach.json +1 -1
- data/config/requests/base/create.json +1 -1
- data/config/requests/base/destroy.json +1 -1
- data/config/requests/base/detach.json +1 -1
- data/config/requests/base/info.json +1 -1
- data/config/requests/base/keepalive.json +1 -1
- data/config/requests/peer/answer.json +1 -1
- data/config/requests/peer/offer.json +1 -1
- data/config/requests/peer/trickle.json +1 -1
- data/lib/generators/ruby_rabbitmq_janus/initializer_generator.rb +3 -0
- data/lib/rrj/admin.rb +34 -0
- data/lib/rrj/errors/error.rb +2 -1
- data/lib/rrj/errors/init.rb +6 -0
- data/lib/rrj/errors/janus/janus.rb +1 -0
- data/lib/rrj/errors/janus/janus_message.rb +8 -4
- data/lib/rrj/errors/janus/janus_processus_keepalive.rb +1 -0
- data/lib/rrj/errors/janus/janus_response.rb +27 -6
- data/lib/rrj/errors/janus/janus_transaction.rb +4 -0
- data/lib/rrj/errors/rabbit/rabbit.rb +3 -1
- data/lib/rrj/errors/tools/config.rb +1 -0
- data/lib/rrj/info.rb +1 -1
- data/lib/rrj/init.rb +37 -169
- data/lib/rrj/janus/messages/admin.rb +1 -2
- data/lib/rrj/janus/messages/message.rb +4 -4
- data/lib/rrj/janus/messages/standard.rb +3 -5
- data/lib/rrj/janus/processus/concurrency.rb +1 -1
- data/lib/rrj/janus/processus/keepalive.rb +10 -4
- data/lib/rrj/janus/responses/admin.rb +31 -0
- data/lib/rrj/janus/responses/event.rb +23 -5
- data/lib/rrj/janus/responses/response.rb +2 -0
- data/lib/rrj/janus/responses/standard.rb +26 -5
- data/lib/rrj/janus/transactions/admin.rb +22 -26
- data/lib/rrj/janus/transactions/handle.rb +13 -8
- data/lib/rrj/janus/transactions/session.rb +25 -7
- data/lib/rrj/janus/transactions/transaction.rb +2 -1
- data/lib/rrj/rabbit/connect.rb +2 -3
- data/lib/rrj/rabbit/publish/admin.rb +1 -6
- data/lib/rrj/rabbit/publish/base_publisher.rb +6 -11
- data/lib/rrj/rabbit/publish/exclusive.rb +1 -0
- data/lib/rrj/rabbit/publish/listener.rb +10 -27
- data/lib/rrj/rabbit/publish/non_exclusive.rb +2 -6
- data/lib/rrj/rabbit/publish/publisher.rb +4 -17
- data/lib/rrj/tools/{config.rb → gem/config.rb} +5 -5
- data/lib/rrj/tools/{log.rb → gem/log.rb} +21 -6
- data/lib/rrj/tools/gem/option.rb +57 -0
- data/lib/rrj/tools/{requests.rb → gem/requests.rb} +0 -0
- data/lib/rrj/tools/replaces/admin.rb +7 -13
- data/lib/rrj/tools/replaces/handle.rb +61 -0
- data/lib/rrj/tools/replaces/replace.rb +57 -27
- data/lib/rrj/tools/replaces/session.rb +34 -0
- data/lib/rrj/tools/replaces/type.rb +63 -11
- data/lib/rrj/tools/tools.rb +4 -3
- data/lib/ruby_rabbitmq_janus.rb +1 -0
- data/spec/request/admin/request_handle_info_spec.rb +13 -7
- data/spec/request/admin/request_handles_spec.rb +20 -0
- data/spec/request/admin/request_sessions_spec.rb +5 -4
- data/spec/request/admin/request_set_locking_debug_spec.rb +16 -0
- data/spec/request/admin/request_set_log_level_spec.rb +16 -0
- data/spec/request/admin/request_tokens_spec.rb +13 -0
- data/spec/request/base/request_attach_spec.rb +6 -9
- data/spec/request/base/request_create_spec.rb +5 -3
- data/spec/request/base/request_destroy_spec.rb +5 -3
- data/spec/request/base/request_detach_spec.rb +6 -7
- data/spec/request/base/request_info_spec.rb +5 -3
- data/spec/request/base/request_keepalive_spec.rb +5 -3
- data/spec/request/peer/request_offer_spec.rb +18 -92
- data/spec/request/peer/request_trickle_spec.rb +9 -28
- data/spec/request/peer/request_trickles_spec.rb +23 -0
- data/spec/rrj/responses/responses_admin_spec.rb +39 -0
- data/spec/rrj/responses/responses_event_spec.rb +25 -0
- data/spec/rrj/responses/responses_response_spec.rb +31 -0
- data/spec/rrj/responses/responses_standard_spec.rb +43 -0
- data/spec/rrj/rrj_config_spec.rb +7 -7
- data/spec/rrj/rrj_rabbitmq_spec.rb +1 -1
- data/spec/rrj/tools/replace_admin_spec.rb +86 -0
- data/spec/rrj/tools/replace_handle_spec.rb +78 -0
- data/spec/rrj/tools/replace_session_spec.rb +66 -0
- data/spec/rrj/tools/replace_spec.rb +69 -0
- data/spec/rrj/tools/type_spec.rb +150 -0
- data/spec/spec_helper.rb +46 -7
- data/spec/support/examples_request.rb +33 -61
- data/spec/support/examples_response.rb +30 -0
- data/spec/support/schemas/request/admin/handles.json +15 -0
- data/spec/support/schemas/request/admin/set_locking_debug.json +13 -0
- data/spec/support/schemas/request/admin/set_log_level.json +11 -0
- data/spec/support/schemas/request/admin/tokens.json +13 -0
- data/spec/support/type.rb +66 -0
- metadata +41 -69
- data/config/requests/peer/trickles.json +0 -7
- data/lib/rrj/tools/replaces/standard.rb +0 -101
- data/spec/fixtures/config/requests/admin/handle_info.json +0 -3
- data/spec/fixtures/config/requests/admin/handles.json +0 -3
- data/spec/fixtures/config/requests/admin/log_level.json +0 -3
- data/spec/fixtures/config/requests/admin/sessions.json +0 -3
- data/spec/fixtures/config/requests/base/attach.json +0 -3
- data/spec/fixtures/config/requests/base/create.json +0 -4
- data/spec/fixtures/config/requests/base/destroy.json +0 -3
- data/spec/fixtures/config/requests/base/detach.json +0 -3
- data/spec/fixtures/config/requests/base/info.json +0 -3
- data/spec/fixtures/config/requests/base/keepalive.json +0 -3
- data/spec/fixtures/config/requests/peer/answer.json +0 -3
- data/spec/fixtures/config/requests/peer/offer.json +0 -3
- data/spec/fixtures/config/requests/peer/trickle.json +0 -3
data/lib/rrj/errors/error.rb
CHANGED
@@ -4,10 +4,11 @@ module RubyRabbitmqJanus
|
|
4
4
|
# Define all error in gem
|
5
5
|
module Errors
|
6
6
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
7
|
-
|
7
|
+
#
|
8
8
|
# Define errors to gems
|
9
9
|
class RRJError < StandardError
|
10
10
|
# Initialize a error standard in this gem
|
11
|
+
#
|
11
12
|
# @param [String] message Text returning in raise
|
12
13
|
# @param [Symbol] level Important to error
|
13
14
|
def initialize(message, level)
|
data/lib/rrj/errors/init.rb
CHANGED
@@ -7,6 +7,7 @@ module RubyRabbitmqJanus
|
|
7
7
|
# Define a super class for all errors in RRJ Class
|
8
8
|
class RRJ < RRJError
|
9
9
|
# Define a message error and level
|
10
|
+
#
|
10
11
|
# @param [String] message Text returning in raise
|
11
12
|
# @param [Symbol] level Level to message in log
|
12
13
|
def initalize(message, level)
|
@@ -17,6 +18,7 @@ module RubyRabbitmqJanus
|
|
17
18
|
# Define an exception if gem dont initialize correctly
|
18
19
|
class InstanciateGemFailed < RRJ
|
19
20
|
# Initialize a error for instanciate class. It's a fatal error
|
21
|
+
#
|
20
22
|
# @param [String] message Text returning in raise
|
21
23
|
def initialize(message)
|
22
24
|
super "Gem is not instanciate correctly : #{message}", :fatal
|
@@ -26,6 +28,7 @@ module RubyRabbitmqJanus
|
|
26
28
|
# Define an error if method message_post given an exception
|
27
29
|
class TransactionSessionFailed < RRJ
|
28
30
|
# Initialize a error for message posting. It's a fatal error
|
31
|
+
#
|
29
32
|
# @param [String] message Text returning in raise
|
30
33
|
def initialize(message)
|
31
34
|
super "Transaction SESSION failed : #{message}", :fatal
|
@@ -35,6 +38,7 @@ module RubyRabbitmqJanus
|
|
35
38
|
# Define a error if method transaction given an exception
|
36
39
|
class TransactionMessageFailed < RRJ
|
37
40
|
# Initialize a error for transaction failed. It's a fatal error
|
41
|
+
#
|
38
42
|
# @param [String] message Text returning in raise
|
39
43
|
def initialize(message)
|
40
44
|
super "Message in a transaction HANDLE failed : #{message}", :fatal
|
@@ -44,6 +48,7 @@ module RubyRabbitmqJanus
|
|
44
48
|
# Define a error if method start_handle given an exception
|
45
49
|
class TransactionHandleFailed < RRJ
|
46
50
|
# Initialize a error for transaction with a handle. It's a fatal error
|
51
|
+
#
|
47
52
|
# @param [String] message Text returning in raise
|
48
53
|
def initialize(message)
|
49
54
|
super "Transaction HANDLE failed : #{message}", :fatal
|
@@ -53,6 +58,7 @@ module RubyRabbitmqJanus
|
|
53
58
|
# define a error for Admin Transaction
|
54
59
|
class TransactionAdminFailed < RRJ
|
55
60
|
# Initialize a error for transaction admin
|
61
|
+
#
|
56
62
|
# @param [String] message Text returning in raise
|
57
63
|
def initialize(message)
|
58
64
|
super "Transaction ADMIN failed : #{message}", :fatal
|
@@ -6,6 +6,7 @@ module RubyRabbitmqJanus
|
|
6
6
|
# Define errors to message sending and response to janus
|
7
7
|
class Janus < RRJError
|
8
8
|
# Initialize a error standard for janus module
|
9
|
+
#
|
9
10
|
# @param [String] message Text returning in raise
|
10
11
|
def initialize(message)
|
11
12
|
super "[JANUS]#{message}", :fatal
|
@@ -3,10 +3,11 @@
|
|
3
3
|
module RubyRabbitmqJanus
|
4
4
|
module Errors
|
5
5
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
6
|
-
|
6
|
+
#
|
7
7
|
# Define an exception for janus message class
|
8
8
|
class JanusMessage < Janus
|
9
9
|
# Initialize a error for janus message module
|
10
|
+
#
|
10
11
|
# @param [String] message Text returning in raise
|
11
12
|
def initialize(message)
|
12
13
|
super "[Message] #{message}"
|
@@ -14,10 +15,11 @@ module RubyRabbitmqJanus
|
|
14
15
|
end
|
15
16
|
|
16
17
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
17
|
-
|
18
|
+
#
|
18
19
|
# Define an exception for janus message to_json
|
19
20
|
class JanusMessageJson < JanusMessage
|
20
21
|
# Initialize a error for janus message in to_json
|
22
|
+
#
|
21
23
|
# @param [String] message Text returning in raise
|
22
24
|
def initialize(message)
|
23
25
|
super "Error transform to json : #{message}"
|
@@ -25,10 +27,11 @@ module RubyRabbitmqJanus
|
|
25
27
|
end
|
26
28
|
|
27
29
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
28
|
-
|
30
|
+
#
|
29
31
|
# Define an exception for janus message to_nice_json
|
30
32
|
class JanusMessagePrettyJson < JanusMessage
|
31
33
|
# Initialize a error for janus message in to_nice_json
|
34
|
+
#
|
32
35
|
# @param [String] message Text returning in raise
|
33
36
|
def initialize(message)
|
34
37
|
super "Error transform to pretty json : #{message}"
|
@@ -36,10 +39,11 @@ module RubyRabbitmqJanus
|
|
36
39
|
end
|
37
40
|
|
38
41
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
39
|
-
|
42
|
+
#
|
40
43
|
# Define an exception for janus message to_hash
|
41
44
|
class JanusMessageHash < JanusMessage
|
42
45
|
# Initialize a error for janus message in to_hash
|
46
|
+
#
|
43
47
|
# @param [String] message Text returning in raise
|
44
48
|
def initialize(message)
|
45
49
|
super "Error transform to hash : #{message}"
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :reek:FeatureEnvy
|
4
|
+
|
3
5
|
module RubyRabbitmqJanus
|
4
6
|
module Errors
|
5
7
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
@@ -7,6 +9,7 @@ module RubyRabbitmqJanus
|
|
7
9
|
# Define an error primary for response
|
8
10
|
class JanusResponse < Janus
|
9
11
|
# Initialize a error for janus response module
|
12
|
+
#
|
10
13
|
# @param [String] message Text returning in raise
|
11
14
|
def initialize(message)
|
12
15
|
super "[Response] #{message}"
|
@@ -14,9 +17,21 @@ module RubyRabbitmqJanus
|
|
14
17
|
end
|
15
18
|
|
16
19
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
20
|
+
#
|
21
|
+
# Define an error for request return
|
22
|
+
class JanusResponseRequest < JanusResponse
|
23
|
+
# Initialize error
|
24
|
+
def initialize(type_rqe, type_msg, message)
|
25
|
+
"Error transform to #{type_rqe} : #{type_msg} -- message : #{message}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
30
|
+
#
|
17
31
|
# Define an error for response initalize
|
18
32
|
class JanusResponseInit < JanusResponse
|
19
33
|
# Initialize a error for janus response module in initializer
|
34
|
+
#
|
20
35
|
# @param [String] message Text returning in raise
|
21
36
|
def initialize(message)
|
22
37
|
super "Error create object : #{message}"
|
@@ -24,20 +39,23 @@ module RubyRabbitmqJanus
|
|
24
39
|
end
|
25
40
|
|
26
41
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
42
|
+
#
|
27
43
|
# Define an exception for json
|
28
|
-
class JanusResponseJson <
|
44
|
+
class JanusResponseJson < JanusResponseRequest
|
29
45
|
# Initialize a error for janus response module in to_json
|
46
|
+
#
|
30
47
|
# @param [String] message Text returning in raise
|
31
48
|
def initialize(message)
|
32
|
-
super
|
33
|
-
"Error transform to JSON : #{message[0]} -- message : #{message[1]}"
|
49
|
+
super('JSON', message[0], message[1])
|
34
50
|
end
|
35
51
|
end
|
36
52
|
|
37
53
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
54
|
+
#
|
38
55
|
# Define an exception for nice_json
|
39
56
|
class JanusResponsePrettyJson < JanusResponse
|
40
57
|
# Initialize a error for janus response module in to_nice_json
|
58
|
+
#
|
41
59
|
# @param [String] message Text returning in raise
|
42
60
|
def initialize(message)
|
43
61
|
super "Error transform to Pretty JSON : #{message}"
|
@@ -45,20 +63,23 @@ module RubyRabbitmqJanus
|
|
45
63
|
end
|
46
64
|
|
47
65
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
66
|
+
#
|
48
67
|
# Define an exception for hash
|
49
|
-
class JanusResponseHash <
|
68
|
+
class JanusResponseHash < JanusResponseRequest
|
50
69
|
# Initialize a error for janus response module in to_hash
|
70
|
+
#
|
51
71
|
# @param [String] message Text returning in raise
|
52
72
|
def initialize(message)
|
53
|
-
super
|
54
|
-
"Error transform to Hash : #{message[0]} -- message : #{message[1]}"
|
73
|
+
super('HASH', message[0], message[1])
|
55
74
|
end
|
56
75
|
end
|
57
76
|
|
58
77
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
78
|
+
#
|
59
79
|
# Define an error for response data
|
60
80
|
class JanusResponseDataId < JanusResponse
|
61
81
|
# Initialize a error for janus response module in data_id
|
82
|
+
#
|
62
83
|
# @param [String] message Text returning in raise
|
63
84
|
def initialize(message)
|
64
85
|
super "Error Data : #{message}"
|
@@ -3,9 +3,11 @@
|
|
3
3
|
module RubyRabbitmqJanus
|
4
4
|
module Errors
|
5
5
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
6
|
+
#
|
6
7
|
# Define an exception for initalizer transaction
|
7
8
|
class JanusTransaction < Janus
|
8
9
|
# Initialize a error for janus transaction class
|
10
|
+
#
|
9
11
|
# @param [String] message Text returning in raise
|
10
12
|
def initialize(message)
|
11
13
|
super "[Transaction]#{message}"
|
@@ -13,9 +15,11 @@ module RubyRabbitmqJanus
|
|
13
15
|
end
|
14
16
|
|
15
17
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
18
|
+
#
|
16
19
|
# Define an exception for running_handle
|
17
20
|
class JanusTransactionHandle < JanusTransaction
|
18
21
|
# Initialize a error for janus transaction handle class
|
22
|
+
#
|
19
23
|
# @param [String] message Text returning in raise
|
20
24
|
def initialize(message)
|
21
25
|
super "[Handle] #{message}"
|
@@ -3,16 +3,18 @@
|
|
3
3
|
module RubyRabbitmqJanus
|
4
4
|
module Errors
|
5
5
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
6
|
+
#
|
6
7
|
# Define errors if connection to rabbitmq is failed
|
7
8
|
class ConnectionRabbitmqFailed < RRJError
|
8
9
|
# Initialize a error for rabbit module. It's a fatal error
|
10
|
+
#
|
9
11
|
# @param [String] message Text returning in raise
|
10
12
|
def initialize(message)
|
11
13
|
super message, :fatal
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
#
|
17
|
+
# Excepetion primary for Rabbit class
|
16
18
|
class Rabbit < RRJError
|
17
19
|
def initialize(message)
|
18
20
|
super "[Rabbit]#{message}", :fatal
|
data/lib/rrj/info.rb
CHANGED
data/lib/rrj/init.rb
CHANGED
@@ -36,196 +36,64 @@ module RubyRabbitmqJanus
|
|
36
36
|
# @rrj = RubyRabbitmqJanus::RRJ.new
|
37
37
|
# => #<RubyRabbitmqJanus::RRJ:0x007 @session=123>
|
38
38
|
def initialize
|
39
|
-
Tools::
|
40
|
-
|
41
|
-
Tools::Requests.instance
|
42
|
-
|
43
|
-
# Create an session while time opening
|
44
|
-
@session = Janus::Concurrencies::Keepalive.instance.session
|
39
|
+
@option = Tools::Option.new
|
40
|
+
@session = @option.keepalive
|
45
41
|
Tools::Log.instance.info "Create an session janus with id : #{@session}"
|
46
42
|
rescue => error
|
47
43
|
raise Errors::InstanciateGemFailed, error
|
48
44
|
end
|
49
45
|
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# @param [String] type
|
53
|
-
# Given a type to request. JSON request writing in 'config/requests/'
|
54
|
-
# @param [Bollean] exclusive
|
55
|
-
# Use an exclusive queue or not
|
56
|
-
# @param [Hash] options Options update in request
|
57
|
-
#
|
58
|
-
# @example Sending an message info in queue 'to-janus'
|
59
|
-
# RubyRabbitmqJanus::RRJ.new.message_simple('base::info', true)
|
60
|
-
# #=> {}
|
61
|
-
# @example Sending an message info in queue exclusive 'ampq.gen-xxxxx'
|
62
|
-
# RubyRabbitmqJanus::RRJ.new.message_simple('base::info')
|
63
|
-
# #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
|
64
|
-
#
|
65
|
-
# @return [RubyRabbitmqJanus::Janus::Responses::Standard]
|
66
|
-
# Give an object response to janus server
|
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
|
72
|
-
Janus::Messages::Standard.new(type, options)
|
73
|
-
end
|
74
|
-
rescue => error
|
75
|
-
raise Errors::TransactionSessionFailed, error
|
76
|
-
end
|
77
|
-
|
78
|
-
# Send an message simple in current session.
|
79
|
-
#
|
80
|
-
# @param [String] type
|
81
|
-
# Given a type to request. JSON request writing in 'config/requests/'
|
82
|
-
# @param [Hash] options Options update in request
|
83
|
-
# @param [Bollean] exclusive
|
84
|
-
# Use an exclusive queue or not
|
85
|
-
#
|
86
|
-
# @example Sending an message create
|
87
|
-
# RubyRabbitmqJanus::RRJ.new.message_session('base::create')
|
88
|
-
# #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
|
89
|
-
#
|
90
|
-
# @return [RubyRabbitmqJanus::Janus::Responses::Standard]
|
91
|
-
# Give an object response to janus server
|
92
|
-
#
|
93
|
-
# @since 1.0.0
|
94
|
-
def message_session(type, options = { 'replace' => {}, 'add' => {} },
|
95
|
-
exclusive = true)
|
96
|
-
Janus::Transactions::Session.new(@session).connect(exclusive) do
|
97
|
-
Janus::Messages::Standard.new(type, use_current_session?(options))
|
98
|
-
end
|
99
|
-
rescue => error
|
100
|
-
raise Errors::TransactionSessionFailed, error
|
101
|
-
end
|
102
|
-
|
103
|
-
# Send a message simple for admin Janus.
|
104
|
-
# **Is used just for sending a message to Janus Monitor/Admin API**. The
|
105
|
-
# queue is exclusive for not transmitting data to anyone.
|
46
|
+
# Start a transaction with Janus. Request use session_id information.
|
106
47
|
#
|
107
|
-
# @param [
|
108
|
-
#
|
109
|
-
#
|
110
|
-
# **This hash must imperatively contains the key `replace`**
|
111
|
-
# @option options [Hash] :replace Contains all fields who be replaced in
|
112
|
-
# request sending to janus.
|
113
|
-
# @option options [Hash] :add Contains all fields adding to request.
|
48
|
+
# @param [Boolean] exclusive Choose if message is storage in exclusive queue
|
49
|
+
# @param [Hash] options
|
50
|
+
# Give a session number for use another session in Janus
|
114
51
|
#
|
115
|
-
# @example
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
# @return [RubyRabbitmqJanus::Janus::Responses::Standard]
|
120
|
-
# Give an object response to janus server
|
52
|
+
# @example Get Janus information
|
53
|
+
# @rrj.start_transaction do |transaction|
|
54
|
+
# response = transaction.publish_message('base::info').to_hash
|
55
|
+
# end
|
121
56
|
#
|
122
|
-
# @since
|
123
|
-
def
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
Janus::Messages::Admin.new(type, options)
|
128
|
-
end
|
129
|
-
rescue => error
|
130
|
-
raise Errors::TransactionAdminFailed, error
|
57
|
+
# @since 2.0.0
|
58
|
+
def start_transaction(exclusive = true, options = {})
|
59
|
+
session = @option.use_current_session?(options)
|
60
|
+
transaction = Janus::Transactions::Session.new(exclusive, session)
|
61
|
+
transaction.connect { yield(transaction) }
|
131
62
|
end
|
132
63
|
|
133
|
-
#
|
134
|
-
#
|
135
|
-
# @param [String] type
|
136
|
-
# Given a type to request. JSON request writing in 'config/requests/'
|
137
|
-
# @param [Hash] options Fields updating in request sending to janus.
|
138
|
-
# **This hash must imperatively contains the key `replace`**
|
139
|
-
# @option options [Hash] :replace Contains all fields who be replaced in
|
140
|
-
# request sending to janus.
|
141
|
-
# @option options [Hash] :add Contains all fields adding to request.
|
64
|
+
# Start a transaction with Janus. Request used session_id/handle_id
|
65
|
+
# information.
|
142
66
|
#
|
143
|
-
# @
|
144
|
-
#
|
145
|
-
#
|
67
|
+
# @param [Boolean] exclusive Choose if message is storage in exclusive queue
|
68
|
+
# @param [Hash] options
|
69
|
+
# Give a session number for use another session in Janus
|
146
70
|
#
|
147
|
-
# @
|
148
|
-
# Give a object response to janus server
|
71
|
+
# @note Use transaction.detach for closing handle in Janus
|
149
72
|
#
|
150
|
-
# @
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
raise Errors::TransactionMessageFailed, error
|
156
|
-
end
|
157
|
-
|
158
|
-
# Define an handle transaction and establish connection with janus
|
159
|
-
#
|
160
|
-
# @param [Bollean] exclusive
|
161
|
-
# Use an exclusive queue or not
|
162
|
-
#
|
163
|
-
# @yield Sending requests to Janus.
|
73
|
+
# @example Send request trickles for exclusive queue
|
74
|
+
# @cde = { 'sdpMid' => '...', sdpMLineIndex => 0, 'candidate' => '...' }
|
75
|
+
# @rrj.start_transaction_handle do |transaction|
|
76
|
+
# transaction.publish_message('base::trickle', @cde)
|
77
|
+
# end
|
164
78
|
#
|
165
|
-
# @example
|
166
|
-
# @
|
167
|
-
#
|
79
|
+
# @example Send request trickles for non exclusive queue
|
80
|
+
# @cde = { 'sdpMid' => '...', sdpMLineIndex => 0, 'candidate' => '...' }
|
81
|
+
# @rrj.start_transaction_handle(false) do |transaction|
|
82
|
+
# transaction.publish_message('base::trickle', @cde)
|
168
83
|
# end
|
169
84
|
#
|
170
|
-
# @
|
85
|
+
# @return [Fixnum] Handle used for transaction
|
171
86
|
#
|
172
|
-
# @since
|
173
|
-
def
|
174
|
-
|
87
|
+
# @since 2.0.0
|
88
|
+
def start_transaction_handle(exclusive = true, options = {})
|
89
|
+
session = @option.use_current_session?(options)
|
90
|
+
handle = @option.use_current_handle?(options)
|
91
|
+
transaction = Janus::Transactions::Handle.new(exclusive, session, handle)
|
175
92
|
transaction.connect { yield(transaction) }
|
176
|
-
rescue => error
|
177
|
-
raise Errors::TransactionHandleFailed, error
|
178
|
-
end
|
179
|
-
|
180
|
-
# Start an short transaction. Create an handle and send one message to
|
181
|
-
# queue. **This queue is not exclusive**, so this message is sending in
|
182
|
-
# queue 'to-janus' and a response is return in queue 'from-janus'.
|
183
|
-
#
|
184
|
-
# @param [String] type
|
185
|
-
# Given a type to request. JSON request writing in 'config/requests/'
|
186
|
-
# @param [Hash] options Fields updating in request sending to janus.
|
187
|
-
# **This hash must imperatively contains the key `replace`**
|
188
|
-
# @option options [Hash] :replace Contains all fields who be replaced in
|
189
|
-
# request sending to janus.
|
190
|
-
# @option options [Hash] :add Contains all fields adding to request.
|
191
|
-
#
|
192
|
-
# @example Send an request trickle
|
193
|
-
# cdn = {
|
194
|
-
# 'candidate' => {
|
195
|
-
# 'sdpMid' => 'video',
|
196
|
-
# 'sdpMLineIndex' => 1,
|
197
|
-
# 'candidate' => '...'
|
198
|
-
# }
|
199
|
-
# }
|
200
|
-
# RubyRabbitmqJanus::RRJ.new.handle_message_simple('peer::trickle', cdn)
|
201
|
-
# #=> { 'janus' => 'trickle', ..., 'candidate' => { ... } }
|
202
|
-
#
|
203
|
-
# @since 1.0.0
|
204
|
-
def handle_message_simple(type, options = { 'replace' => {}, 'add' => {} })
|
205
|
-
transaction = Janus::Transactions::Handle.new(session?(options),
|
206
|
-
false, handle?(options))
|
207
|
-
transaction.connect { message_handle(type, transaction, options) }
|
208
|
-
rescue => error
|
209
|
-
raise Errors::TransactionHandleFailed, error
|
210
93
|
end
|
211
94
|
|
212
95
|
private
|
213
96
|
|
214
|
-
|
215
|
-
{ 'session_id' => @session } unless option.key?('session_id')
|
216
|
-
end
|
217
|
-
|
218
|
-
def session?(options)
|
219
|
-
return_value(options, 'session_id', @session)
|
220
|
-
end
|
221
|
-
|
222
|
-
def handle?(options)
|
223
|
-
return_value(options, 'handle_id', 0)
|
224
|
-
end
|
225
|
-
|
226
|
-
def return_value(opt, key, value)
|
227
|
-
replace = opt['replace']
|
228
|
-
replace.key?(key) ? replace[key] : value
|
229
|
-
end
|
97
|
+
attr_reader :option
|
230
98
|
end
|
231
99
|
end
|