ruby_rabbitmq_janus 1.1.1 → 1.1.2

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
  SHA1:
3
- metadata.gz: 4d867ab33a737631d0e24dbfef98cf530a567fbe
4
- data.tar.gz: e49d2887b98ad7d79977ad3ed082bd619aa63494
3
+ metadata.gz: 4878f39325bc19260e50a953e77acfadfda78eb9
4
+ data.tar.gz: bea625c521c11a72fec35463c9dcd502d0cb740f
5
5
  SHA512:
6
- metadata.gz: fbb8ea88cddb61406065484e14f9a2e775a14b91d5b4b0b70c930cf598cddcc57c497a1abfdcd26b71ed74bfccaa8f5ba8cab6a593983ede389f4c8758b5f9aa
7
- data.tar.gz: e70bf30e2202049ee6ccc0acfb08876835022f4541ce96c9b4b9421df17818f8f80b53b13ee305a4656e3aef529a2c24f7bfb00e870803a0e13d3eddd59363c5
6
+ metadata.gz: 4d6da165b55dac47eabfcf856b8689f053a673de18b7df026c2364803f135d6dcdf494fd74f8f5b462fb81fea9dcb6b3be7846355d331841ee9fdf2b75de2144
7
+ data.tar.gz: 4742b640660dbc6aee4e4c8dff7a1bb99f9b8fd8af5281c211dde372ec571cb8c92178a59f951149bb587170482197f59ad1673a82678efd7e0b4b87ecd56ded
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.1'
6
+ VERSION = '1.1.2'
7
7
 
8
8
  # Define a summary description to gem
9
9
  SUMMARY = 'Ruby RabbitMQ Janus'
data/lib/rrj/init.rb CHANGED
@@ -15,9 +15,10 @@ module RubyRabbitmqJanus
15
15
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
16
16
  # Initialize gem and create automatically an session with Janus
17
17
  # @!attribute [r] session
18
+ # @return [Fixnum] Renturn an session number created in instanciate gem
18
19
  # :reek:BooleanParameter and :reek:ControlParameter and :reek:DataClump
19
20
  class RRJ
20
- attr_reader :session, :event
21
+ attr_reader :session
21
22
 
22
23
  # Returns a new instance of RubyRabbitmqJanus
23
24
  def initialize
@@ -119,7 +120,19 @@ module RubyRabbitmqJanus
119
120
  @transaction.handle_running_stop
120
121
  end
121
122
 
122
- # Start an short transaction, this queue is not exclusive
123
+ # Start an short transaction. Create an handle and send a message to queue.
124
+ # This queue is not exclusive, so this message is sending in queue 'to-janus' and a
125
+ # response is return in queue 'from-janus'
126
+ # @example Send an request trickle
127
+ # candidate = {
128
+ # 'candidate' => {
129
+ # 'sdpMid' => 'video',
130
+ # 'sdpMLineIndex' => 1,
131
+ # 'candidate' => '...'
132
+ # }
133
+ # }
134
+ # RubyRabbitmqJanus::RRJ.new.handle_message_simple('peer::trickle', candidate)
135
+ # #=> { 'janus' => 'trickle', ..., 'candidate' => { 'completed' : true } } }
123
136
  def handle_message_simple(type, replace = {}, add = {})
124
137
  @transaction = Janus::Transactions::Handle.new(@session)
125
138
  @transaction.handle_connect_and_stop(false) do
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:InstanceVariableAssumption and :reek:NilCheck
3
+ # :reek:TooManyInstanceVariables and :reek:TooManyStatements
2
4
 
3
5
  module RubyRabbitmqJanus
4
6
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
5
7
  module Janus
6
8
  module Concurrencies
7
9
  # For listen standard queue ("from-janus" by default)
8
- # :reek:InstanceVariableAssumption and :reek:NilCheck
9
- # :reek:TooManyInstanceVariables and :reek:TooManyStatements
10
10
  class Event < Concurrency
11
11
  include Singleton
12
12
 
@@ -21,6 +21,11 @@ module RubyRabbitmqJanus
21
21
  request['jsep'] if contains_jsep?
22
22
  end
23
23
 
24
+ # Return a couple session_id and handle_id
25
+ def keys
26
+ [request['session_id'], request['sender']]
27
+ end
28
+
24
29
  private
25
30
 
26
31
  # Test if response contains jsep data
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:TooManyMethods and :reek:DuplicateMethodCall
2
3
 
3
4
  module RubyRabbitmqJanus
4
5
  module Janus
@@ -6,7 +7,6 @@ module RubyRabbitmqJanus
6
7
  module Responses
7
8
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
8
9
  # Read and decryt a response to janus
9
- # :reek:TooManyMethods
10
10
  class Response
11
11
  # Instanciate a response
12
12
  def initialize(response_janus)
@@ -49,7 +49,6 @@ module RubyRabbitmqJanus
49
49
  attr_accessor :request
50
50
 
51
51
  # Analysis response and send exception if janus return an error
52
- # :reek:DuplicateMethodCall
53
52
  def analysis
54
53
  raise Errors::JanusResponseSimple, @request if error_simple?
55
54
  raise Errors::JanusResponsePlugin, @request['plugindata']['data'] \
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:TooManyInstanceVariables and :reek:ControlParameter
3
+ # :reek:ControlParameter and :reek:BooleanParameter
2
4
 
3
5
  module RubyRabbitmqJanus
4
6
  module Janus
@@ -6,7 +8,6 @@ module RubyRabbitmqJanus
6
8
  module Transactions
7
9
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
8
10
  # This class work with janus and send a series of message
9
- # :reek:TooManyInstanceVariables
10
11
  class Transaction
11
12
  # Initialize an transaction
12
13
  def initialize(session)
@@ -30,7 +31,6 @@ module RubyRabbitmqJanus
30
31
  attr_reader :rabbit, :session, :response, :handle, :publish
31
32
 
32
33
  # determine queue used
33
- # :reek:ControlParameter and :reek:BooleanParameter
34
34
  def choose_queue(exclusive)
35
35
  chan = @rabbit.channel
36
36
  @publish = if exclusive
@@ -52,7 +52,6 @@ module RubyRabbitmqJanus
52
52
  end
53
53
 
54
54
  # Read a response if is a exclusive message
55
- # :reek:ControlParameter
56
55
  def read_response(publish, exclusive)
57
56
  if exclusive
58
57
  Tools::Log.instance.info '... and read a janus response'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:FeatureEnvy
2
3
 
3
4
  module RubyRabbitmqJanus
4
5
  module Rabbit
@@ -49,7 +50,6 @@ module RubyRabbitmqJanus
49
50
  private
50
51
 
51
52
  # Read option for bunny instance (connection with rabbitmq)
52
- # :reek:FeatureEnvy
53
53
  def read_options_server
54
54
  cfg = Tools::Config.instance.options['rabbit']
55
55
  opts = {}
@@ -13,6 +13,7 @@ module RubyRabbitmqJanus
13
13
  subscribe_to_queue
14
14
  end
15
15
 
16
+ # Send an message to queue and waiting a response
16
17
  def send_a_message(request)
17
18
  super(request)
18
19
  return_response
@@ -12,6 +12,7 @@ module RubyRabbitmqJanus
12
12
  subscribe_to_queue
13
13
  end
14
14
 
15
+ # Send an message to queue and waiting a response
15
16
  def send_a_message(request)
16
17
  super(request)
17
18
  return_response
@@ -24,6 +24,7 @@ module RubyRabbitmqJanus
24
24
  def listen_events
25
25
  lock.synchronize do
26
26
  condition.wait(lock)
27
+ Tools::Log.instance.info 'Janus event received .. treatment ..'
27
28
  yield @response.event, @response.data, @response.jsep
28
29
  end
29
30
  end
@@ -13,6 +13,7 @@ module RubyRabbitmqJanus
13
13
  super(exchange)
14
14
  end
15
15
 
16
+ # Send an message to queue
16
17
  def send_a_message(request)
17
18
  super(request)
18
19
  end
@@ -31,7 +31,6 @@ module RubyRabbitmqJanus
31
31
  # Load configuration file yaml
32
32
  # @return [Yaml] Configuration file
33
33
  # @param file [String] Path to configuration file (with name)
34
- # :reek:UtilityFunction { public_methods_only: true }
35
34
  def load_configuration(file)
36
35
  Tools::Log.instance.info("Loading configuration file : #{file}")
37
36
  YAML.load(File.read(file))
data/lib/rrj/tools/env.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:UtilityFunction
2
3
 
3
4
  module RubyRabbitmqJanus
4
5
  # Contains all tools necessary in this gem
5
6
  module Tools
6
7
  # Class for tools used in gem
7
- # :reek:UtilityFunction
8
8
  class Env
9
9
  include Singleton
10
10
 
data/lib/rrj/tools/log.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:Attribute and :reek:UtilityFunction
2
3
 
3
4
  module RubyRabbitmqJanus
4
5
  module Tools
@@ -17,7 +18,6 @@ module RubyRabbitmqJanus
17
18
  UNKNOWN: Logger::UNKNOWN
18
19
  }.freeze
19
20
 
20
- # This method smell :reek:Attribute
21
21
  attr_accessor :level, :progname
22
22
 
23
23
  # Returns a new instance to Log
@@ -93,7 +93,6 @@ module RubyRabbitmqJanus
93
93
  log
94
94
  end
95
95
 
96
- # This method smell :reek:UtilityFunction
97
96
  def test_level?(this_level)
98
97
  this_level >= Log.instance.level ? true : false
99
98
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:TooManyMethods and :reek:NilCheck
2
3
 
3
4
  module RubyRabbitmqJanus
4
5
  module Tools
5
6
  # Format message request with good data to HASH format
6
7
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
7
- # :reek:TooManyMethods
8
8
  # rubocop:disable Metrics/ClassLength
9
9
  class Replace
10
10
  # Initialize a tool replace
@@ -73,6 +73,7 @@ module RubyRabbitmqJanus
73
73
  Tools::Log.instance.warn "Error candidate replace : #{message}"
74
74
  end
75
75
 
76
+ # Save candidate or candidates in request
76
77
  def save_candidate(value)
77
78
  if @opts.key?('candidates')
78
79
  @request['candidates'] = value
@@ -135,7 +136,6 @@ module RubyRabbitmqJanus
135
136
  end
136
137
 
137
138
  # Test presence of key in many hash
138
- # :reek:NilCheck
139
139
  def test_presence?(presence_of_key)
140
140
  @opts.key?(presence_of_key) && \
141
141
  @request.key?('body') && \
data/listen.rb CHANGED
@@ -6,19 +6,16 @@ require 'ruby_rabbitmq_janus'
6
6
  @t = RubyRabbitmqJanus::RRJ.new
7
7
  @e = RubyRabbitmqJanus::Janus::Concurrencies::Event.instance
8
8
 
9
- # :reek:NilCheck and :reek:TooManyStatements
10
9
  def case_event(data, jsep)
11
- puts "REASON : Event : #{data.class} -- #{data}"
12
- case data['videocontrol']
13
- when 'joined'
14
- puts 'Joined request ...'
15
- @t.handle_message_simple('channel::offer', jsep)
16
- end
17
- update_jsep(jsep) unless jsep.nil?
10
+ puts "REASON : Event : #{data} -- #{jsep}"
11
+ end
12
+
13
+ def case_hangup(data)
14
+ puts "REASON : Hangup : #{data}"
18
15
  end
19
16
 
20
- def update_jsep(jsep)
21
- puts "JSEP : #{jsep}"
17
+ def case_error(data)
18
+ puts "REASON : Error : #{data}"
22
19
  end
23
20
 
24
21
  def case_stop
@@ -26,14 +23,17 @@ def case_stop
26
23
  Thread.current.stop
27
24
  end
28
25
 
29
- events = lambda do |reason, data = nil, jsep = nil|
26
+ events = lambda do |reason, data, jsep = nil|
30
27
  puts "Execute block code with reason : #{reason}"
31
28
  case reason
32
29
  when 'event' then case_event(data, jsep)
30
+ when 'hangup' then case_hangup(data)
31
+ when 'error' then case_error(data)
33
32
  when 'stop' then case_stop
34
33
  else
35
34
  puts 'REASON default'
36
35
  end
36
+ puts " --\n\r"
37
37
  end
38
38
 
39
39
  puts '## Start listen Block'
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: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-17 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler