class Punchblock::Connection::Freeswitch
Attributes
event_handler[RW]
stream[R]
translator[R]
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/punchblock/connection/freeswitch.rb, line 11 def initialize(options = {}) @translator = Translator::Freeswitch.new self @stream_options = options.values_at(:host, :port, :password) @stream = new_fs_stream super() end
Public Instance Methods
handle_event(event)
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 33 def handle_event(event) event_handler.call event if event_handler.respond_to?(:call) end
run()
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 18 def run pb_logger.debug "Starting the RubyFS stream" start_stream raise DisconnectedError end
stop()
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 24 def stop stream.shutdown translator.terminate end
write(command, options)
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 29 def write(command, options) translator.async.execute_command command, options end
Private Instance Methods
event_mask()
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 43 def event_mask %w{CHANNEL_PARK CHANNEL_ANSWER CHANNEL_STATE CHANNEL_HANGUP CHANNEL_BRIDGE CHANNEL_UNBRIDGE CHANNEL_EXECUTE_COMPLETE DTMF RECORD_STOP} end
new_fs_stream()
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 39 def new_fs_stream RubyFS::Stream.new(*@stream_options, lambda { |e| translator.async.handle_es_event e }, event_mask) end
start_stream()
click to toggle source
# File lib/punchblock/connection/freeswitch.rb, line 47 def start_stream @stream = new_fs_stream unless @stream.alive? @stream.run end