Class: RubyRabbitmqJanus::RRJ
- Inherits:
-
Object
- Object
- RubyRabbitmqJanus::RRJ
- Defined in:
- lib/rrj/init.rb
Overview
# RubyRabbitmqJanus - RRJ
Initialize RRJ gem and create automatically a session with janus and sending a keepalive message. The Time To Live is configured in yaml configuration file ‘config/default.yml` or if you a customize config in `config/ruby-rabbitmq-janus.yml`.
Instance Attribute Summary collapse
-
#session ⇒ Fixnum
readonly
Return an session number created when this gem is instanciate.
Instance Method Summary collapse
-
#cleanup_connection! ⇒ Object
Delete all resources to JanusInstance reference.
-
#handle_endpoint_private(options = {}) ⇒ Object
Create a transaction between Apps and Janus.
-
#handle_endpoint_public(options = {}) ⇒ Object
Create a transaction between Apps and Janus in private queue.
-
#initialize ⇒ RRJ
constructor
Return a new instance of RubyRabbitmqJanus.
-
#session_endpoint_private(options = {}) ⇒ Object
Create a transaction between Apps and Janus in queue private.
-
#session_endpoint_public(options = {}) ⇒ Object
Create a transaction between Apps and Janus in queue public.
Constructor Details
Instance Attribute Details
#session ⇒ Fixnum (readonly)
Return an session number created when this gem is instanciate. It’s janus who creates the number of the session.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/rrj/init.rb', line 37 class RRJ attr_reader :session # Return a new instance of RubyRabbitmqJanus. # # @example Create a instance to this gem # @rrj = RubyRabbitmqJanus::RRJ.new # => #<RubyRabbitmqJanus::RRJ:0x007 @session=123> def initialize @option = Tools::Option.new end # Create a transaction between Apps and Janus in queue public # # @params [Hash] options # @options [String] :instance (mandatory id cluster is enabled) # @options [Integer] :session_id # @options [Hash] :replace # @options [Hash] :add # # @example Create a session # instance : { 'instance' => 42 } # @rrj.session_endpoint_public(instance) do |transaction| # transaction.publish_message('base::create') # end # # @example Destroy session in instance # options = { 'instance' => 42, 'session_id' => 71984735765 } # @rrj.session_endpoint_public(options) do |transaction| # transaction.publish_message('base::destroy', options) # end # # @since 2.7.0 def session_endpoint_public( = {}) session = @option.use_current_session?() transaction = Janus::Transactions::Session.new(false, session) transaction.connect { yield(transaction) } end # Create a transaction between Apps and Janus in queue private # # @params [Hash] options # @options [String] :instance (mandatory id cluster is enabled) # @options [Integer] :session_id # @options [Hash] :replace # @options [Hash] :add # # @example Create a session # instance : { 'instance' => 42 } # @rrj.session_endpoint_public(instance) do |transaction| # transaction.publish_message('base::create') # end # # @example Destroy session in instance # options = { 'instance' => 42, 'session_id' => 71984735765 } # @rrj.session_endpoint_public(options) do |transaction| # transaction.publish_message('base::destroy', options) # end # # @since 2.7.0 def session_endpoint_private( = {}) session = @option.use_current_session?() transaction = Janus::Transactions::Session.new(true, session) transaction.connect { yield(transaction) } end # Create a transaction between Apps and Janus in private queue # # @param [Hash] options # @options [String] :instance (mandatory id cluster is enabled) # @options [Integer] :session_id (mandatory) # @options [Integer] :handle_id # @options [Hash] :replace # @options [Hash] :add # # @example Post a offer # options = { # 'instance' => 42, # 'session_id' => 71984735765, # 'handle_id' => 56753748917, # 'replace' => { # 'sdp' => 'v=0\r\no=[..more sdp stuff..]' # } # } # @rrj.handle_endpoint_public(options) do |transaction| # transaction.publish_message('peer::offer', options) # end # # @since 2.7.0 def handle_endpoint_public( = {}) session = @option.use_current_session?() handle = @option.use_current_handle?() instance = ['instance'] || 1 transaction = Janus::Transactions::Handle.new(false, session, handle, instance) transaction.connect { yield(transaction) } end # Create a transaction between Apps and Janus # # @param [Hash] options # @options [String] :instance (mandatory id cluster is enabled) # @options [Integer] :session_id (mandatory) # @options [Integer] :handle_id # @options [Hash] :replace # @options [Hash] :add # # @example Post a answer # options = { # 'instance' => 42, # 'session_id' => 71984735765, # 'handle_id' => 56753748917, # 'replace' => { # 'sdp' => 'v=0\r\no=[..more sdp stuff..]' # } # } # @rrj.handle_endpoint_private(options) do |transaction| # transaction.publish_message('peer::answer', options) # end # # @since 2.7.0 def handle_endpoint_private( = {}) session = @option.use_current_session?() handle = @option.use_current_handle?() instance = ['instance'] || 1 transaction = Janus::Transactions::Handle.new(true, session, handle, instance) transaction.connect { yield(transaction) } end # Delete all resources to JanusInstance reference. # Warning: All data in database and Janus Instance is delete # # @since 2.1.0 def cleanup_connection! Models::JanusInstance.destroys end private attr_reader :option end |
Instance Method Details
#cleanup_connection! ⇒ Object
Delete all resources to JanusInstance reference. Warning: All data in database and Janus Instance is delete
175 176 177 |
# File 'lib/rrj/init.rb', line 175 def cleanup_connection! Models::JanusInstance.destroys end |
#handle_endpoint_private(options = {}) ⇒ Object
Create a transaction between Apps and Janus
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/rrj/init.rb', line 160 def handle_endpoint_private( = {}) session = @option.use_current_session?() handle = @option.use_current_handle?() instance = ['instance'] || 1 transaction = Janus::Transactions::Handle.new(true, session, handle, instance) transaction.connect { yield(transaction) } end |
#handle_endpoint_public(options = {}) ⇒ Object
Create a transaction between Apps and Janus in private queue
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rrj/init.rb', line 126 def handle_endpoint_public( = {}) session = @option.use_current_session?() handle = @option.use_current_handle?() instance = ['instance'] || 1 transaction = Janus::Transactions::Handle.new(false, session, handle, instance) transaction.connect { yield(transaction) } end |
#session_endpoint_private(options = {}) ⇒ Object
Create a transaction between Apps and Janus in queue private
97 98 99 100 101 |
# File 'lib/rrj/init.rb', line 97 def session_endpoint_private( = {}) session = @option.use_current_session?() transaction = Janus::Transactions::Session.new(true, session) transaction.connect { yield(transaction) } end |
#session_endpoint_public(options = {}) ⇒ Object
Create a transaction between Apps and Janus in queue public
70 71 72 73 74 |
# File 'lib/rrj/init.rb', line 70 def session_endpoint_public( = {}) session = @option.use_current_session?() transaction = Janus::Transactions::Session.new(false, session) transaction.connect { yield(transaction) } end |