Class: Punchblock::Connection::Asterisk
- Inherits:
-
GenericConnection
- Object
- GenericConnection
- Punchblock::Connection::Asterisk
- Defined in:
- lib/punchblock/connection/asterisk.rb
Instance Attribute Summary collapse
-
#ami_client ⇒ Object
readonly
Returns the value of attribute ami_client.
-
#event_handler ⇒ Object
Returns the value of attribute event_handler.
-
#translator ⇒ Object
readonly
Returns the value of attribute translator.
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize(options = {}) ⇒ Asterisk
constructor
A new instance of Asterisk.
- #run ⇒ Object
- #stop ⇒ Object
- #write(command, options) ⇒ Object
Methods inherited from GenericConnection
#connected?, #not_ready!, #ready!
Constructor Details
#initialize(options = {}) ⇒ Asterisk
Returns a new instance of Asterisk.
11 12 13 14 15 |
# File 'lib/punchblock/connection/asterisk.rb', line 11 def initialize( = {}) @ami_client = RubyAMI::Client.new .merge(:event_handler => lambda { |event| translator.handle_ami_event! event }, :logger => pb_logger) @translator = Translator::Asterisk.new @ami_client, self, [:media_engine] super() end |
Instance Attribute Details
#ami_client ⇒ Object (readonly)
Returns the value of attribute ami_client.
8 9 10 |
# File 'lib/punchblock/connection/asterisk.rb', line 8 def ami_client @ami_client end |
#event_handler ⇒ Object
Returns the value of attribute event_handler.
9 10 11 |
# File 'lib/punchblock/connection/asterisk.rb', line 9 def event_handler @event_handler end |
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
8 9 10 |
# File 'lib/punchblock/connection/asterisk.rb', line 8 def translator @translator end |
Instance Method Details
#handle_event(event) ⇒ Object
31 32 33 |
# File 'lib/punchblock/connection/asterisk.rb', line 31 def handle_event(event) event_handler.call event end |
#run ⇒ Object
17 18 19 20 |
# File 'lib/punchblock/connection/asterisk.rb', line 17 def run ami_client.start raise DisconnectedError end |
#stop ⇒ Object
22 23 24 25 |
# File 'lib/punchblock/connection/asterisk.rb', line 22 def stop translator.shutdown! ami_client.stop end |
#write(command, options) ⇒ Object
27 28 29 |
# File 'lib/punchblock/connection/asterisk.rb', line 27 def write(command, ) translator.execute_command! command, end |