lib/rrj/init.rb in ruby_rabbitmq_janus-2.6.0 vs lib/rrj/init.rb in ruby_rabbitmq_janus-2.7.0.pre.267
- old
+ new
@@ -58,18 +58,74 @@
# @rrj.start_transaction do |transaction|
# response = transaction.publish_message('base::info').to_hash
# end
#
# @since 2.0.0
+ # @deprecated Use {#session_endpoint_public} or
+ # {#session_endpoint_private} instead.
def start_transaction(exclusive = true, options = {})
session = @option.use_current_session?(options)
transaction = Janus::Transactions::Session.new(exclusive, session)
transaction.connect { yield(transaction) }
rescue
raise Errors::RRJ::StartTransaction.new(exclusive, options)
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(options = {})
+ session = @option.use_current_session?(options)
+ 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(options = {})
+ session = @option.use_current_session?(options)
+ transaction = Janus::Transactions::Session.new(true, session)
+ transaction.connect { yield(transaction) }
+ end
+
# Start a transaction with Janus. Request used session_id/handle_id
# information.
#
# @param [Boolean] exclusive Choose if message is storage in exclusive queue
# @param [Hash] options
@@ -90,10 +146,12 @@
# end
#
# @return [Fixnum] Handle used for transaction
#
# @since 2.0.0
+ # @deprecated Use {#handle_endpoint_public}
+ # or {#handle_endpoint_private} instead.
def start_transaction_handle(exclusive = true, options = {})
session = @option.use_current_session?(options)
handle = @option.use_current_handle?(options)
instance = options['instance'] || 1
transaction = Janus::Transactions::Handle.new(exclusive,
@@ -101,9 +159,77 @@
handle,
instance)
transaction.connect { yield(transaction) }
rescue
raise Errors::RRJ::StartTransactionHandle, exclusive, options
+ 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(options = {})
+ session = @option.use_current_session?(options)
+ handle = @option.use_current_handle?(options)
+ instance = options['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(options = {})
+ session = @option.use_current_session?(options)
+ handle = @option.use_current_handle?(options)
+ instance = options['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
#