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
Constructor Details
#initialize(options = {}) ⇒ Asterisk
Returns a new instance of Asterisk.
9 10 11 12 13 |
# File 'lib/punchblock/connection/asterisk.rb', line 9 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 super() end |
Instance Attribute Details
#ami_client ⇒ Object (readonly)
Returns the value of attribute ami_client.
6 7 8 |
# File 'lib/punchblock/connection/asterisk.rb', line 6 def ami_client @ami_client end |
#event_handler ⇒ Object
Returns the value of attribute event_handler.
7 8 9 |
# File 'lib/punchblock/connection/asterisk.rb', line 7 def event_handler @event_handler end |
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
6 7 8 |
# File 'lib/punchblock/connection/asterisk.rb', line 6 def translator @translator end |
Instance Method Details
#handle_event(event) ⇒ Object
29 30 31 |
# File 'lib/punchblock/connection/asterisk.rb', line 29 def handle_event(event) event_handler.call event end |
#run ⇒ Object
15 16 17 18 |
# File 'lib/punchblock/connection/asterisk.rb', line 15 def run pb_logger.debug "Starting the RubyAMI client" ami_client.start end |
#stop ⇒ Object
20 21 22 23 |
# File 'lib/punchblock/connection/asterisk.rb', line 20 def stop translator.shutdown! ami_client.stop end |
#write(command, options) ⇒ Object
25 26 27 |
# File 'lib/punchblock/connection/asterisk.rb', line 25 def write(command, ) translator.execute_command! command, end |