Class: RubyRabbitmqJanus::Janus::TransactionHandle

Inherits:
TransactionSession show all
Defined in:
lib/rrj/janus/transactions/handle.rb

Overview

This class work with janus and send a series of message

Author:

Direct Known Subclasses

TransactionAdmin

Instance Attribute Summary

Attributes inherited from Transaction

#handle, #publish, #rabbit, #response, #session

Instance Method Summary collapse

Methods inherited from TransactionSession

#session_connect

Methods inherited from Transaction

#choose_queue, #connect, #create_handle, #initialize, #send_a_message

Constructor Details

This class inherits a constructor from RubyRabbitmqJanus::Janus::Transaction

Instance Method Details

#handle_connect(exclusive) ⇒ Object

Initialize connection to Rabbit and Janus



9
10
11
12
13
14
15
# File 'lib/rrj/janus/transactions/handle.rb', line 9

def handle_connect(exclusive)
  rabbit.transaction_long do
    choose_queue(exclusive)
    create_handle
    yield
  end
end

#handle_connect_and_stop(exclusive) ⇒ Object

Initialize connection to Rabbit and Janus and close after sending an received a response



19
20
21
22
23
24
25
# File 'lib/rrj/janus/transactions/handle.rb', line 19

def handle_connect_and_stop(exclusive)
  rabbit.transaction_short do
    choose_queue(exclusive)
    create_handle
    yield
  end
end

#handle_running_stopObject

Stop an handle running



28
29
30
# File 'lib/rrj/janus/transactions/handle.rb', line 28

def handle_running_stop
  publish_message_handle('base::detach')
end

#publish_message_handle(type, options = {}) ⇒ Object

Publish an message in handle



33
34
35
36
37
# File 'lib/rrj/janus/transactions/handle.rb', line 33

def publish_message_handle(type, options = {})
  opts = { 'session_id' => session, 'handle_id' => handle }
  msg = Janus::Message.new(type, opts.merge!(options))
  Janus::Response.new(publish.send_a_message(msg))
end