RubyGems Navigation menu

freeswitcher 0.4.4

FreeSWITCHeR Copyright © 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry) Distributed under the terms of the MIT License. ========================================================== ABOUT —– A ruby library for interacting with the “FreeSWITCH” (www.freeswitch.org) opensource telephony platform REQUIREMENTS ———— * ruby (>= 1.8) * eventmachine (If you wish to use Outbound and Inbound listener) USAGE —– An Outbound Event Listener Example that reads and returns DTMF input: ——————————————————————– Simply just create a subclass of FSR::Listner::Outbound and all new calls/sessions will invoke the “session_initiated” callback method. NOTE: FSR uses blocks within the ‘session_inititated’ method to ensure that the next “freeswich command” is not executed until the previous “Freeswitch command” has finished. (Basically a continuation) This is kicked off by “answer do”. #!/usr/bin/ruby require ‘fsr’ require ‘fsr/listener/outbound’ class OutboundDemo < FSR::Listener::Outbound def session_initiated exten = @session.headers FSR::Log.info “*** Answering incoming call from #{exten}” answer do FSR::Log.info “***Reading DTMF from #{exten}” read(“/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav”, 4, 10, “input”, 7000) do |read_var| FSR::Log.info “***Success, grabbed #{read_var.to_s.strip} from #{exten}” # Tell the caller what they entered speak(“Got the DTMF of: #{read_var.to_s.strip}”) do #Hangup the call hangup end end end end end FSR.start_oes! OutboundDemo, :port => 8084, :host => “127.0.0.1” An Inbound Event Socket Listener example using FreeSWITCHeR’s hook system: ————————————————————————– #!/usr/bin/ruby require ‘pp’ require ‘fsr’ require “fsr/listener/inbound” # EXAMPLE 1 # This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you’re after. See the next example FSL::Inbound.add_event_hook(:CHANNEL_CREATE) { FSR::Log.info “*** [#{event.content}] Channel created - greetings from the hook!” } # EXAMPLE 2 # Define a method to handle CHANNEL_HANGUP events. def custom_channel_hangup_handler(event) FSR::Log.info “*** [#{event.content}] Channel hangup. The event:” pp event end # This adds a hook for EXAMPLE 2 FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) { custom_channel_hangup_handler(event) } # Start FSR Inbound Listener FSR.start_ies!(FSL::Inbound, :host => “localhost”, :port => 8021) An Inbound Event Socket Listener example using the on_event callback method instead of hooks: ——————————————————————————————— #!/usr/bin/ruby require ‘pp’ require ‘fsr’ require “fsr/listener/inbound” class IesDemo < FSR::Listener::Inbound def on_event pp event.headers pp event.content end end FSR.start_ies!(IesDemo, :host => “localhost”, :port => 8021, :auth => “ClueCon”) An example of using FSR::CommandSocket to originate a new call in irb: ———————————————————————- irb(main):001:0> require ‘fsr’ => true irb(main):002:0> FSR.load_all_commands => [:sofia, :originate] irb(main):003:0> sock = FSR::CommandSocket.new => #<FSR::CommandSocket:0xb7a89104 @server=“127.0.0.1”, @socket=#<TCPSocket:0xb7a8908c>, @port=“8021”, @auth=“ClueCon”> irb(main):007:0> sock.originate(:target => ‘sofia/gateway/carlos/8179395222’, :endpoint => FSR::App::Bridge.new(“user/bougyman”)).run => {“Job-UUID”=>“732075a4-7dd5-4258-b124-6284a82a5ae7”, “body”=>“”, “Content-Type”=>“command/reply”, “Reply-Text”=>“+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7”} SUPPORT ——- Home page at code.rubyists.com/projects/fs #rubyists on FreeNode

Gemfile:
=

安装:
=

版本列表:

  1. 0.8.0 November 26, 2012 (60.5 KB)
  2. 0.7.1 January 13, 2012 (60.0 KB)
  3. 0.7.0 January 12, 2012 (60.0 KB)
  4. 0.6.18 January 11, 2012 (59.5 KB)
  5. 0.6.17 January 11, 2012 (59.5 KB)
  6. 0.4.4 December 06, 2009 (49.0 KB)
显示所有版本 (共 53 个)

Runtime 依赖 (1):

业主:

作者:

  • Jayson Vaughn, Michael Fellinger, Kevin Berry, TJ Vanderpoel

SHA 256 校验和:

=

下载总量 255,993

这个版本 4,983

版本发布:

许可:

需要的 Ruby 版本:

链接: