Class: Punchblock::Connection::Freeswitch
- Inherits:
-
GenericConnection
- Object
- GenericConnection
- Punchblock::Connection::Freeswitch
- Defined in:
- lib/punchblock/connection/freeswitch.rb
Instance Attribute Summary collapse
-
#event_handler ⇒ Object
Returns the value of attribute event_handler.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#translator ⇒ Object
readonly
Returns the value of attribute translator.
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize(options = {}) ⇒ Freeswitch
constructor
A new instance of Freeswitch.
- #run ⇒ Object
- #stop ⇒ Object
- #write(command, options) ⇒ Object
Methods inherited from GenericConnection
#connected?, #not_ready!, #ready!
Constructor Details
#initialize(options = {}) ⇒ Freeswitch
Returns a new instance of Freeswitch.
11 12 13 14 15 16 |
# File 'lib/punchblock/connection/freeswitch.rb', line 11 def initialize( = {}) @translator = Translator::Freeswitch.new self @stream_options = .values_at(:host, :port, :password) @stream = new_fs_stream super() end |
Instance Attribute Details
#event_handler ⇒ Object
Returns the value of attribute event_handler.
9 10 11 |
# File 'lib/punchblock/connection/freeswitch.rb', line 9 def event_handler @event_handler end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
8 9 10 |
# File 'lib/punchblock/connection/freeswitch.rb', line 8 def stream @stream end |
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
8 9 10 |
# File 'lib/punchblock/connection/freeswitch.rb', line 8 def translator @translator end |
Instance Method Details
#handle_event(event) ⇒ Object
33 34 35 |
# File 'lib/punchblock/connection/freeswitch.rb', line 33 def handle_event(event) event_handler.call event if event_handler.respond_to?(:call) end |
#run ⇒ Object
18 19 20 21 22 |
# File 'lib/punchblock/connection/freeswitch.rb', line 18 def run pb_logger.debug "Starting the RubyFS stream" start_stream raise DisconnectedError end |
#stop ⇒ Object
24 25 26 27 |
# File 'lib/punchblock/connection/freeswitch.rb', line 24 def stop stream.shutdown translator.terminate end |
#write(command, options) ⇒ Object
29 30 31 |
# File 'lib/punchblock/connection/freeswitch.rb', line 29 def write(command, ) translator.async.execute_command command, end |