Module: FSR

Defined in:
lib/rack/middleware.rb,
lib/fsr.rb,
lib/fsr/app.rb,
lib/fsr/cmd.rb,
lib/fsr/app/log.rb,
lib/fsr/app/say.rb,
lib/fsr/app/set.rb,
lib/fsr/ostruct.rb,
lib/fsr/version.rb,
lib/fsr/app/fifo.rb,
lib/fsr/app/read.rb,
lib/fsr/cmd/chat.rb,
lib/fsr/cmd/enum.rb,
lib/fsr/cmd/kill.rb,
lib/fsr/database.rb,
lib/fsr/listener.rb,
lib/fsr/app/limit.rb,
lib/fsr/app/speak.rb,
lib/fsr/cmd/calls.rb,
lib/fsr/cmd/fsctl.rb,
lib/fsr/cmd/sofia.rb,
lib/fsr/app/answer.rb,
lib/fsr/app/bridge.rb,
lib/fsr/app/hangup.rb,
lib/fsr/cmd/status.rb,
lib/fsr/model/call.rb,
lib/fsr/model/enum.rb,
lib/fsr/model/tier.rb,
lib/fsr/utils/dtmf.rb,
lib/fsr/fake_socket.rb,
lib/fsr/model/agent.rb,
lib/fsr/model/queue.rb,
lib/fsr/app/fs_break.rb,
lib/fsr/app/fs_sleep.rb,
lib/fsr/app/playback.rb,
lib/fsr/app/transfer.rb,
lib/fsr/cmd/channels.rb,
lib/fsr/event_socket.rb,
lib/fsr/file_methods.rb,
lib/fsr/app/uuid_dump.rb,
lib/fsr/cmd/originate.rb,
lib/fsr/cmd/uuid_dump.rb,
lib/fsr/database/core.rb,
lib/fsr/listener/mock.rb,
lib/fsr/model/channel.rb,
lib/fsr/app/callcenter.rb,
lib/fsr/app/conference.rb,
lib/fsr/app/pre_answer.rb,
lib/fsr/app/ring_ready.rb,
lib/fsr/app/valet_park.rb,
lib/fsr/cmd/conference.rb,
lib/fsr/cmd/valet_info.rb,
lib/fsr/command_socket.rb,
lib/fsr/app/execute_app.rb,
lib/fsr/app/uuid_getvar.rb,
lib/fsr/app/uuid_setvar.rb,
lib/fsr/cmd/call_center.rb,
lib/fsr/cmd/sched_hangup.rb,
lib/fsr/cmd/sofia/status.rb,
lib/fsr/listener/inbound.rb,
lib/fsr/app/bind_meta_app.rb,
lib/fsr/cmd/sofia/profile.rb,
lib/fsr/cmd/sofia_contact.rb,
lib/fsr/cmd/uuid_transfer.rb,
lib/fsr/listener/outbound.rb,
lib/fsr/cmd/sched_transfer.rb,
lib/fsr/cmd/uuid_send_dtmf.rb,
lib/fsr/database/call_limit.rb,
lib/fsr/listener/inbound/event.rb,
lib/fsr/app/play_and_get_digits.rb,
lib/fsr/listener/header_and_content_response.rb

Overview

TODO Separate these models into their own subdirectories

Defined Under Namespace

Modules: App, Cmd, Database, Listener, Model, Rack, Utils Classes: CommandSocket, EventSocket, FakeSocket, OpenStruct

Constant Summary collapse

FS_INSTALL_PATHS =

Global configuration options

["/usr/local/freeswitch", "/opt/freeswitch", "/usr/freeswitch", "/home/freeswitch/freeswitch"]
DEFAULT_CALLER_ID_NUMBER =
'8675309'
DEFAULT_CALLER_ID_NAME =
"FSR"
ROOT =
Pathname(__FILE__).dirname.expand_path.freeze
FSR_ROOT =
Pathname(__FILE__).join("..").dirname.expand_path.freeze
FS_ROOT =

FreeSWITCH $$base_dir

find_freeswitch_install
FS_CONFIG_PATH =

FreeSWITCH conf dir

FS_DB_PATH = nil
FS_DB_PATH =

FreeSWITCH db dir

(FS_ROOT + 'db').freeze
VERSION =
"0.7.1"

Class Method Summary collapse

Class Method Details

.find_freeswitch_installObject

Find the FreeSWITCH install path if running FSR on a local box with FreeSWITCH installed. This will enable sqlite db access



85
86
87
88
89
90
91
92
93
# File 'lib/fsr.rb', line 85

def self.find_freeswitch_install
  good_path = FS_INSTALL_PATHS.find do |fs_path|
    FSR::Log.warn("#{fs_path} is not a directory!") if File.exists?(fs_path) && !File.directory?(fs_path)
    FSR::Log.warn("#{fs_path} is not readable by this user!") if File.exists?(fs_path) && !File.readable?(fs_path)
    Dir["#{fs_path}/{conf,db}/"].size == 2 ? fs_path.to_s : nil
  end
  FSR::Log.warn("No FreeSWITCH install found, database and configuration functionality disabled") if  good_path.nil?
  good_path
end

.load_all_applicationsObject

Load all FSR::App classes



50
51
52
53
# File 'lib/fsr.rb', line 50

def self.load_all_applications
  require "fsr/app"
  App.load_all
end

.load_all_commands(retrying = false) ⇒ Object

Load all FSR::Cmd classes



43
44
45
46
47
# File 'lib/fsr.rb', line 43

def self.load_all_commands(retrying = false)
  require 'fsr/command_socket'
  load_all_applications
  Cmd.load_all
end

.start_ies!(klass, args = {}) ⇒ Object

Method to start EM for Inbound Event Socket

Parameters:

  • klass (FSR::Listener::Inbound)

    An Inbound Listener class, to be started by EM.run

  • args (::Hash) (defaults to: {})

    A hash of options, may contain :host [String] The host/ip to bind to (Default: “localhost”) :port [Integer] the port to listen on (Default: 8021)

See Also:



72
73
74
75
76
77
78
79
80
# File 'lib/fsr.rb', line 72

def self.start_ies!(klass, args = {})
  args[:port] ||= 8021
  args[:host] ||= "localhost"
  EM.run do
    EventMachine::connect(args[:host], args[:port], klass, args)
    FSR::Log.info "*** FreeSWITCHer Inbound EventSocket Listener connected to #{args[:host]}:#{args[:port]} ***"
    FSR::Log.info "*** http://code.rubyists.com/projects/fs"
  end
end

.start_oes!(klass, args = {}) ⇒ Object

Method to start EM for Outbound Event Socket



56
57
58
59
60
61
62
63
64
# File 'lib/fsr.rb', line 56

def self.start_oes!(klass, args = {})
  port = args.delete(:port) || "8084"
  host = args.delete(:host) || "localhost"
  EM.run do
    EventMachine::start_server(host, port, klass, args)
    FSR::Log.info "*** FreeSWITCHer Outbound EventSocket Listener on #{host}:#{port} ***"
    FSR::Log.info "*** http://code.rubyists.com/projects/fs"
  end
end