ruby_rabbitmq_janus 1.0.4 → 1.0.5
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 +3 -1
- data/lib/rrj/info.rb +1 -1
- data/lib/rrj/init.rb +3 -3
- data/lib/rrj/janus/processus/event.rb +24 -9
- data/lib/rrj/janus/transactions/admin.rb +1 -1
- data/lib/rrj/rabbit/publish/admin.rb +1 -1
- data/listen.rb +16 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 315daf05da37138a7cbd49ee535669ade8fba813
|
4
|
+
data.tar.gz: 00bf29601cb4f70693875466db4a52f5aa488188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d931cd33d7c2a7ceac9fb2ed395f188fc9fb7d41637462f02c3e5afffa2493e3cb431701c5036f26f25ac61b7beb1a83eedf47a561604be8b7c6e725a07af4f
|
7
|
+
data.tar.gz: 256f28e5db381ad148dc8c2ab7c8a8a558e97e6a60666b2775b0d865bc73e261caf66bc0d2776310dc3d8d4f3f5206fd30b4c4f57d08c2871b80e4e8d17aa70c
|
@@ -9,7 +9,9 @@ module RubyRabbitmqJanus
|
|
9
9
|
# Create an initializer
|
10
10
|
def copy_initializer
|
11
11
|
initializer 'ruby_rabbitmq_janus.rb' do
|
12
|
-
"# frozen_string_literal: true\n\n
|
12
|
+
"# frozen_string_literal: true\n\n" \
|
13
|
+
"::RRJ = RubyRabbitmqJanus::RRJ.new\n"\
|
14
|
+
'::Events = RubyRabbitmqJanus::Janus::Concurrencies::Event.instance'
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/rrj/info.rb
CHANGED
data/lib/rrj/init.rb
CHANGED
@@ -93,7 +93,7 @@ module RubyRabbitmqJanus
|
|
93
93
|
|
94
94
|
# Define an handle transaction and establish connection with janus
|
95
95
|
def start_handle(exclusive = false)
|
96
|
-
@transaction
|
96
|
+
@transaction = Janus::Transactions::Handle.new(@session)
|
97
97
|
@transaction.handle_connect(exclusive) { yield }
|
98
98
|
rescue => error
|
99
99
|
raise Errors::RRJErrorHandle, error
|
@@ -101,7 +101,7 @@ module RubyRabbitmqJanus
|
|
101
101
|
|
102
102
|
# Define an handle admin transaction and establish connection with janus
|
103
103
|
def start_handle_admin
|
104
|
-
@transaction
|
104
|
+
@transaction = Janus::Transactions::Admin.new(@session)
|
105
105
|
@transaction.handle_connect { yield }
|
106
106
|
rescue => error
|
107
107
|
raise Errors::RRJErrorHandle, error
|
@@ -114,7 +114,7 @@ module RubyRabbitmqJanus
|
|
114
114
|
|
115
115
|
# Start an short transaction, this queue is not exclusive
|
116
116
|
def handle_message_simple(type, replace = {}, add = {})
|
117
|
-
@transaction
|
117
|
+
@transaction = Janus::Transactions::Handle.new(@session)
|
118
118
|
@transaction.handle_connect_and_stop(false) do
|
119
119
|
message_handle(type, replace, add).for_plugin
|
120
120
|
end
|
@@ -5,30 +5,45 @@ module RubyRabbitmqJanus
|
|
5
5
|
module Janus
|
6
6
|
module Concurrencies
|
7
7
|
# For listen standard queue ("from-janus" by default)
|
8
|
-
|
8
|
+
# :reek:InstanceVariableAssumption and :reek:NilCheck
|
9
|
+
# :reek:TooManyInstanceVariables and :reek:TooManyStatements
|
10
|
+
class Event
|
9
11
|
include Singleton
|
10
12
|
|
11
13
|
# Initialize Event object. Is used for listen an standard out queue to Janus
|
12
14
|
def initialize
|
13
15
|
@publish = @response = nil
|
14
|
-
|
16
|
+
Tools::Log.instance.info "Create an thread -- #{self.class.name}"
|
17
|
+
@rabbit = Rabbit::Connect.new
|
18
|
+
@lock = Mutex.new
|
19
|
+
@condition = ConditionVariable.new
|
20
|
+
@thread_subscribe = Thread.new { initialize_thread }
|
15
21
|
end
|
16
22
|
|
17
23
|
# Start listen queue and work with each message reading
|
18
24
|
def listen(&block)
|
19
|
-
|
20
|
-
|
25
|
+
@thread_subscribe.join
|
26
|
+
puts 'LISTEN !!'
|
27
|
+
@thread_listen = Thread.new do
|
28
|
+
puts 'LISTEN in thread !!'
|
29
|
+
Thread.pass
|
21
30
|
@publish.event_received(&block)
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
25
34
|
private
|
26
35
|
|
27
|
-
#
|
28
|
-
def
|
29
|
-
|
30
|
-
@
|
31
|
-
|
36
|
+
# Initialize a thread
|
37
|
+
def initialize_thread
|
38
|
+
Thread.pass
|
39
|
+
@rabbit.transaction_long do
|
40
|
+
@publish = Rabbit::Publisher::Listener.new(@rabbit)
|
41
|
+
@response = @publish.listen_events
|
42
|
+
@thread_listen&.join # Call if not nil
|
43
|
+
end
|
44
|
+
rescue Interrupt
|
45
|
+
Tools::Log.instance.info "Stop transaction #{self.class.name}"
|
46
|
+
@rabbit.close
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
data/listen.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# :reek:NilCheck and :reek:TooManyStatements
|
2
|
+
# frozen_string_literal: true
|
4
3
|
|
5
4
|
require 'ruby_rabbitmq_janus'
|
6
5
|
|
7
6
|
@t = RubyRabbitmqJanus::RRJ.new
|
7
|
+
@events = RubyRabbitmqJanus::Janus::Concurrencies::Event.instance
|
8
8
|
|
9
|
+
# :reek:NilCheck and :reek:TooManyStatements
|
9
10
|
def case_event(data, jsep)
|
10
|
-
puts "Event : #{data.class} -- #{data}"
|
11
|
+
puts "REASON : Event : #{data.class} -- #{data}"
|
11
12
|
case data['videocontrol']
|
12
13
|
when 'joined'
|
13
14
|
puts 'Joined request ...'
|
@@ -24,32 +25,32 @@ def update_jsep(jsep)
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def case_hangup
|
27
|
-
puts 'Hangup'
|
28
|
-
Thread.stop
|
28
|
+
puts 'REASON : Hangup'
|
29
|
+
Thread.current.stop
|
29
30
|
end
|
30
31
|
|
31
32
|
def case_stop
|
32
|
-
puts 'Stop'
|
33
|
-
Thread.stop
|
33
|
+
puts 'REASON : Stop'
|
34
|
+
Thread.current.stop
|
34
35
|
end
|
35
36
|
|
36
37
|
def case_error
|
37
|
-
puts 'Error ...'
|
38
|
+
puts 'REASON : Error ...'
|
38
39
|
end
|
39
40
|
|
40
|
-
puts
|
41
|
-
|
41
|
+
puts '## Start listen Block'
|
42
|
+
@events.listen do |reason, data, jsep|
|
42
43
|
case reason
|
43
44
|
when 'event' then case_event(data, jsep)
|
44
45
|
when 'hangup' then case_hangup
|
45
46
|
when 'stop' then case_stop
|
46
47
|
when 'error' then case_error
|
47
48
|
else
|
48
|
-
puts
|
49
|
+
puts 'REASON default'
|
49
50
|
end
|
50
51
|
end
|
51
|
-
puts
|
52
|
+
puts '## End listen block'
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
puts 'apps running'
|
55
|
+
loop do
|
56
|
+
end
|