Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'sinatra' # Get with "gem install sinatra"
- require 'restful_adhearsion'
- require 'pp'
- #Create our Adhearsion object connected to the RESTful API of Adhearsion
- Adhearsion = RESTfulAdhearsion.new(:host => "localhost",
- :port => 5000,
- :user => "jicksta",
- :password => "roflcopterz")
- # You'll need to change this for your own format.
- # Note: this will soon be handled by the Call Routing DSL in Adhearsion.
- def format_number(number)
- "IAX2/username:password@test.voipjet.com/#{number}"
- #""
- end
- get "/callurl" do
- options = { :channel => format_number(params[:source]),
- :context => "clicktocall",
- :priority => "1",
- :exten => "1000",
- :async => 'true',
- :variable => "destination=" + format_number(params[:destination]) }
- #Originates a call over the AMI interface
- Adhearsion.originate options
- "ok".to_json
- end
- post "/call" do
- options = { :channel => format_number(params[:source]),
- :context => "clicktocall",
- :priority => "1",
- :exten => "1000",
- :async => 'true',
- :variable => "destination=" + format_number(params[:destination]) }
- #Originates a call over the AMI interface
- Adhearsion.originate options
- "ok".to_json
- end
- post "/hangup" do
- #Get the channel of the active call, then hang it up
- channel_of_active_call = Adhearsion.hangup_channel_with_destination params[:call_to_hangup]
- "ok".to_json
- end
- get '/status' do
- # The line below will return either {result:"alive"} or {result:"dead"} to the browser
- {:result => Adhearsion.call_with_destination(params[:destination])}.to_json
- end
- get '/' do
- #Build our web form that has the JQuery sprinkled in
- <<-HTML
- <html>
- (some html)
- HTML
- end
Add Comment
Please, Sign In to add comment